GEMC  1.8
Geant4 Monte-Carlo Framework
FMT_hitprocess.cc
Go to the documentation of this file.
1 // %%%%%%%%%%%%
2 // gemc headers
3 // %%%%%%%%%%%%
4 #include "FMT_hitprocess.h"
5 #include "fmt_strip.h"
6 
8 {
9  string hd_msg = Opt.args["LOG_MSG"].args + " FMT Hit Process " ;
10  double VERB = Opt.args["HIT_VERBOSITY"].arg;
11 
12  PH_output out;
13  out.identity = aHit->GetId();
14 
15  HCname = "FMT 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  // FMT 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 
104 vector<identifier> FMT_HitProcess :: ProcessID(vector<identifier> id, G4Step* aStep, detector Detector, gemc_opts Opt)
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 fmt_strip fmts;
114  fmts.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 = fmts.FindStrip(layer-1, sector-1, x, y, z);
120 double depe = aStep->GetTotalEnergyDeposit();
121  //cout << "resolMM " << layer << " " << x << " " << y << " " << z << " " << depe << " " << aStep->GetTrack()->GetTrackID() << endl;
122  vector<double> multi_hit = fmts.FindStrip(layer-1, sector-1, x, y, z, depe);
123 
124  int n_multi_hits = multi_hit.size()/2;
125 
126  // closest strip
127  //yid[4].id = (int) multi_hit[0];
128  yid[3].id = (int) multi_hit[0];
129 
130  yid[0].id_sharing = multi_hit[1];
131  yid[1].id_sharing = multi_hit[1];
132  yid[2].id_sharing = multi_hit[1];
133  yid[3].id_sharing = multi_hit[1];
134  // yid[4].id_sharing = multi_hit[1];
135 
136  // additional strip
137  for(int h=1; h<n_multi_hits; h++)
138  {
139  for(int j=0; j<3; j++)
140  {
141  identifier this_id;
142  this_id.name = yid[j].name;
143  this_id.rule = yid[j].rule;
144  this_id.id = yid[j].id;
145  this_id.time = yid[j].time;
146  this_id.TimeWindow = yid[j].TimeWindow;
147  this_id.TrackId = yid[j].TrackId;
148  this_id.id_sharing = multi_hit[3];
149  yid.push_back(this_id);
150  }
151  // last id is strip
152  identifier this_id;
153  this_id.name = yid[3].name;
154  this_id.rule = yid[3].rule;
155  this_id.id = (int) multi_hit[2];
156  this_id.time = yid[3].time;
157  this_id.TimeWindow = yid[3].TimeWindow;
158  this_id.TrackId = yid[3].TrackId;
159  this_id.id_sharing = multi_hit[3];
160  yid.push_back(this_id);
161  }
162 
163  return yid;
164 }
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
void fill_infos()
Definition: fmt_strip.cc:9
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
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
PH_output ProcessHit(MHit *, gemc_opts)
Method to process the hit.
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
vector< double > FindStrip(int layer, int sector, double x, double y, double z, double Edep)
Definition: fmt_strip.cc:46
Definition: MHit.h:29
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.
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 > GetEdep()
Definition: MHit.h:76
string rule
"manual" or "ncopy"
Definition: identifier.h:30
vector< int > dgtz
Digitized information.
Definition: MPHBaseClass.h:27