GEMC  2.3
Geant4 Monte-Carlo Framework
bst_strip.cc
Go to the documentation of this file.
1 // gemc headers
2 #include "bst_strip.h"
3 
4 #include <iostream>
5 #include <cmath>
6 #include <cstdlib>
7 
8 // CLHEP units
9 #include "CLHEP/Units/PhysicalConstants.h"
10 using namespace CLHEP;
11 
13 {
14 
15  intersensors = (0.11 + 0.002)*mm; // gap between sensors + microgap
16  alpha = 3.0*deg; // max angle of the strips
17  pitch = 0.156*mm; // pitch of the strips
18 
19  // number of cards by sector for each layer
20  NSensors.push_back(3); NSensors.push_back(3);
21  NSensors.push_back(3); NSensors.push_back(3);
22  NSensors.push_back(3); NSensors.push_back(3);
23  NSensors.push_back(3); NSensors.push_back(3);
24 
25  DZ_inLength = 0.984*mm; // size of the band of dead zones all around in the length of the card
26  DZ_inWidth = 0.835*mm; // size of the band of dead zones all around in the width of the card
27  SensorLength = 111.625*mm; // length of 1 Sensor
28  SensorWidth = 42.02*mm; // width 1 Sensor
29 
30  // Number of strips
31  Nstrips = (int) floor((SensorWidth-2.0*DZ_inLength)/pitch) - 1;
32 
33 }
34 
35 
36 vector<double> bst_strip::FindStrip(int layer, int sector, int isens, G4ThreeVector Lxyz)
37 {
38 
39  // the return vector is always in pairs.
40  // The first number is the ID,
41  // the second number is the sharing percentage
42  // layer and sector are the indexes (i.e. layer is the actual layern-1)
43  vector<double> strip_id;
44 
45  int StripHit = -1;
46  double minDist = 999; // distance between actual x and x of the k-strip at the actual z
47  double dalpha = alpha/((float)Nstrips);
48 
49  // local x position in the sensor: need to add 1/2 active area
50  double lx = Lxyz.x() + SensorWidth/2.0 - DZ_inLength;
51 
52  // local z position in the module: need to add 1/2 active area + 1(2) full sensor lengths if on sensor 2(3)
53  double lz = Lxyz.z() + SensorLength/2.0 - DZ_inWidth + (isens-1)*(SensorLength + intersensors) ;
54 
55  // particle must be in the z and x active area of the sensor
56  if( fabs(Lxyz.z()) < (SensorLength/2.0 - DZ_inWidth) && fabs(Lxyz.x()) < (SensorWidth/2.0 - DZ_inLength))
57  {
58  // looping over all strips to find the closest
59  // to the point
60  for(int k=0; k<Nstrips; k++)
61  {
62  // angle of the k-strip
63  double alpha_k = k*dalpha;
64 
65  // strip equation is z = mz + intcp
66  double intcp = 0;
67  double m = 0;
68 
69  if(layer%2 == 0)
70  {
71  // intercept: for layer A it starts from the top of the active area of the sensor in sector 1
72  // which is at positive local x
73  intcp = SensorWidth - 2*DZ_inLength - (k+1)*pitch ;
74  m = -tan(alpha_k/rad);
75  }
76 
77  if(layer%2 == 1)
78  {
79  // intercept: for layer B it starts from the bottom of the active area of the sensor in sector 1
80  // which is at negative local x
81  intcp = (k+1)*pitch ;
82  m = tan(alpha_k/rad);
83  }
84 
85  // x position of the strip according to the active local z position
86  double stripx = intcp + m*lz;
87 
88  if(fabs(lx - stripx) < fabs(minDist))
89  {
90  minDist = lx - stripx;
91  StripHit = k+1;
92  }
93 
94  }
95  }
96 
97 
98 
99  if(StripHit != -1)
100  {
101  // correcting for z positioning inside the module
102  double dpitch = pitch + lz*tan(dalpha/rad);
103 
104  // for even layers x is proportional to strip number.
105  // for odd layers x is inversly proportional to strip number
106  int moduleDirection = 1;
107  if(layer%2 == 0)
108  moduleDirection = -1;
109 
110  // one strip only, all energy to it
111  if(fabs(minDist)<=dpitch/4.0)
112  {
113  strip_id.push_back(StripHit);
114  strip_id.push_back(1);
115  }
116  // two hits, on the right of the strip (left if odd layers)
117  // 10% loss due to capacitance between strip and backplane
118  if(minDist>dpitch/4.0)
119  {
120  strip_id.push_back(StripHit);
121  strip_id.push_back(0.45);
122  if(StripHit + moduleDirection != 0)
123  {
124  strip_id.push_back(StripHit + moduleDirection);
125  strip_id.push_back(0.45);
126  }
127  //if(StripHit == 1) cout << "charged shared with " << StripHit + moduleDirection << endl;
128  }
129  // two hits, on the left of the strip (right if odd layers)
130  // 10% loss due to capacitance between strip and backplane
131  if(minDist<-dpitch/4.0)
132  {
133  strip_id.push_back(StripHit);
134  strip_id.push_back(0.45);
135  if(StripHit - moduleDirection != 0)
136  {
137  strip_id.push_back(StripHit - moduleDirection);
138  strip_id.push_back(0.45);
139  }
140  //if(StripHit == 1) cout << "charged shared with " << StripHit + moduleDirection << endl;
141  }
142  }
143  else
144  {
145  strip_id.push_back(-5);
146  strip_id.push_back(1);
147  }
148  return strip_id;
149 
150 
151 }
152 
153 
void fill_infos()
Definition: bst_strip.cc:12
vector< double > FindStrip(int layer, int sector, int isens, G4ThreeVector Lxyz)
Definition: bst_strip.cc:36