GEMC  2.3
Geant4 Monte-Carlo Framework
bst_hitprocess.cc
Go to the documentation of this file.
1 // gemc headers
2 #include "bst_hitprocess.h"
3 #include "bst_strip.h"
4 
5 // CLHEP units
6 #include "CLHEP/Units/PhysicalConstants.h"
7 using namespace CLHEP;
8 
9 // geant4
10 #include "Randomize.hh"
11 
12 map<string, double> bst_HitProcess :: integrateDgt(MHit* aHit, int hitn)
13 {
14  map<string, double> dgtz;
15  vector<identifier> identity = aHit->GetId();
16 
17  class bst_strip bsts;
18  bsts.fill_infos();
19 
20  // double checking dimensions
21  double SensorLength = 2.0*aHit->GetDetector().dimensions[2]/mm; // length of 1 card
22  double SensorWidth = 2.0*aHit->GetDetector().dimensions[0]/mm; // width 1 card
23 
24  if(SensorLength != bsts.SensorLength || SensorWidth != bsts.SensorWidth)
25  cout << " Warning: dimensions mismatch between sensor reconstruction dimensions and gemc card dimensions." << endl << endl;
26 
27  int layer = 2*identity[0].id + identity[1].id - 2 ;
28  int sector = identity[2].id;
29  int card = identity[3].id;
30  int strip = identity[4].id;
31 
32  trueInfos tInfos(aHit);
33 
34  // 1 DAC is 0.87 keV
35  // If deposited energy is below 26.1 keV there is no hit.
36  // If deposited energy is above 117.47 keV the hit will be in the last ADC bin
37  // (from 117.47 keV to infinity), which means overflow.
38  // I.e. there are 7 bins plus an overflow bin.
39 
40  double minHit = 0.0261*MeV;
41  double maxHit = 0.11747*MeV;
42  double deltaADC = maxHit - minHit;
43  int adc = floor( 7*(tInfos.eTot - minHit)/deltaADC);
44  int adchd = floor(8196*(tInfos.eTot - minHit)/deltaADC);
45 
46  if(tInfos.eTot>maxHit)
47  {
48  adc = 7;
49  adchd = 8196;
50  }
51  if(tInfos.eTot<minHit)
52  {
53  adc = -5;
54  adchd = -5000;
55  }
56 
57  if(verbosity>4)
58  {
59  cout << log_msg << " layer: " << layer << " sector: " << sector << " Card: " << card << " Strip: " << strip
60  << " x=" << tInfos.x << " y=" << tInfos.y << " z=" << tInfos.z << endl;
61  }
62 
63  dgtz["hitn"] = hitn;
64  dgtz["layer"] = layer;
65  dgtz["sector"] = sector;
66  dgtz["strip"] = strip;
67  dgtz["ADC"] = adc;
68  dgtz["ADCHD"] = adchd;
69  dgtz["time"] = tInfos.time;
70  dgtz["bco"] = (int) 255*G4UniformRand();
71 
72  return dgtz;
73 }
74 
75 
76 
77 vector<identifier> bst_HitProcess :: processID(vector<identifier> id, G4Step* aStep, detector Detector)
78 {
79  vector<identifier> yid = id;
80 
81  G4ThreeVector xyz = aStep->GetPostStepPoint()->GetPosition();
82 
83  G4ThreeVector Lxyz = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()
84  ->GetTopTransform().TransformPoint(xyz);
85 
86  class bst_strip bsts;
87  bsts.fill_infos();
88 
89  int layer = 2*yid[0].id + yid[1].id - 2 ;
90  int sector = yid[2].id;
91  int isensor = yid[3].id;
92 
93  vector<double> multi_hit = bsts.FindStrip(layer-1, sector-1, isensor, Lxyz);
94 
95  int n_multi_hits = multi_hit.size()/2;
96 
97  // closest strip
98  yid[4].id = (int) multi_hit[0];
99 
100  yid[0].id_sharing = multi_hit[1];
101  yid[1].id_sharing = multi_hit[1];
102  yid[2].id_sharing = multi_hit[1];
103  yid[3].id_sharing = multi_hit[1];
104  yid[4].id_sharing = multi_hit[1];
105 
106  // additional strip
107  for(int h=1; h<n_multi_hits; h++)
108  {
109  for(int j=0; j<4; j++)
110  {
111  identifier this_id;
112  this_id.name = yid[j].name;
113  this_id.rule = yid[j].rule;
114  this_id.id = yid[j].id;
115  this_id.time = yid[j].time;
116  this_id.TimeWindow = yid[j].TimeWindow;
117  this_id.TrackId = yid[j].TrackId;
118  this_id.id_sharing = multi_hit[3];
119  yid.push_back(this_id);
120  }
121  // last id is strip
122  identifier this_id;
123  this_id.name = yid[4].name;
124  this_id.rule = yid[4].rule;
125  this_id.id = (int) multi_hit[2];
126  this_id.time = yid[4].time;
127  this_id.TimeWindow = yid[4].TimeWindow;
128  this_id.TrackId = yid[4].TrackId;
129  this_id.id_sharing = multi_hit[3];
130  yid.push_back(this_id);
131 
132  }
133 
134  return yid;
135 }
136 
137 
138 
139 map< string, vector <int> > bst_HitProcess :: multiDgt(MHit* aHit, int hitn)
140 {
141  map< string, vector <int> > MH;
142 
143  return MH;
144 }
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
vector< identifier > processID(vector< identifier >, G4Step *, detector)
double verbosity
void fill_infos()
Definition: bst_strip.cc:12
vector< identifier > GetId()
Definition: Hit.h:103
int id
manually assing ID. 0 if "ncopy" (will be set at hit processing time)
Definition: identifier.h:39
map< string, vector< int > > multiDgt(MHit *, int)
string name
Name of the detector.
Definition: identifier.h:37
double time
Definition: HitProcess.h:43
double z
Definition: HitProcess.h:41
double eTot
Definition: HitProcess.h:40
double x
Definition: HitProcess.h:41
double TimeWindow
Time Window. If abs(steptime - time) is smaller than TimeWindow, it&#39;s the same hit.
Definition: identifier.h:41
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:42
map< string, double > integrateDgt(MHit *, int)
double SensorWidth
Definition: bst_strip.h:19
double SensorLength
Definition: bst_strip.h:18
Definition: Hit.h:22
double y
Definition: HitProcess.h:41
vector< double > FindStrip(int layer, int sector, int isens, G4ThreeVector Lxyz)
Definition: bst_strip.cc:36
double id_sharing
A single step can generate multiple identifiers. This variable represent the percentage sharing of th...
Definition: identifier.h:43
double time
Time of the first step.
Definition: identifier.h:40
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
Definition: detector.h:77
detector GetDetector()
Definition: Hit.h:108
string rule
"manual" or "ncopy"
Definition: identifier.h:38