GEMC  1.8
Geant4 Monte-Carlo Framework
fst_strip.cc
Go to the documentation of this file.
1 // %%%%%%%%%%%%%
2 // gemc headers
3 // %%%%%%%%%%%%%
4 #include "fst_strip.h"
5 
6 #include <iostream>
7 #include <cmath>
8 
10 {
11  // all dimensions are in mm
12 
13  Pi = 3.14159265358;
14  interlayer = 2.75; // distance between 2 layers of a superlayer
15  intersuperlayer = 20.0; // distance between 2 superlayers
16  Nsector=15; // number of sectors for each layer
17 
18  alpha = (360.0/Nsector/2.0)*Pi/180.0; // angle of the strips
19  pitch = 0.150; // pitch of the strips
20 
21  DZ = 0.934; // size of the band of dead zones
22  Rmin = 17.0; // inner radius of disks
23  Rint = Rmin + 42.949; // intermediate radius of disks
24  Rmax = (Rmin+45.419+159.581); // outer radius of disks
25  Z_1stlayer = 190.1; // z position of the 1st layer
26 
27  // z of the upstream part of the layer
28  Z0.push_back(Z_1stlayer);
29  Z0.push_back(Z0[0]+interlayer);
30  Z0.push_back(Z_1stlayer+intersuperlayer);
31  Z0.push_back(Z0[2]+interlayer);
32  Z0.push_back(Z_1stlayer+2.*intersuperlayer);
33  Z0.push_back(Z0[4]+interlayer);
34 
35 
36  // mid angle of the sector
37  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
38  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
39  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
40  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
41  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
42  MidTile.push_back((360.0/Nsector/2.0)*Pi/180.0);
43 
44  // Number of strips
45  Nstrips = (int) floor((2.*Rmax*tan(alpha)-2.*DZ)/pitch);
46 
47 }
48 
49 
50 
51 
52 
53 int fst_strip::FindStrip(int layer, int sector, double x, double y, double z)
54 {
55  // 1st define phi of the hit point
56  double phi;
57  if(x>0 && y>=0) phi = atan(y/x);
58  else if(x>0 && y<0) phi = 2.*Pi+atan(y/x);
59  else if(x<0) phi = Pi+atan(y/x);
60  else if(x==0 && y>0) phi = Pi/2.;
61  else if(x==0 && y<0) phi = 3.*Pi/2.;
62  else phi = 0; // x = y = 0, phi not defined
63 
64  // now find the tile number
65  int ti=0;
66  double theta_tmp=0;
67  for(int t=0; t<Nsector; t++)
68  {
69  theta_tmp = MidTile[layer]+2.*t*Pi/Nsector;
70  if(theta_tmp>2.*Pi) theta_tmp = theta_tmp - 2.*Pi;
71  if(theta_tmp<0) theta_tmp = theta_tmp + 2.*Pi;
72  if(fabs(phi-theta_tmp)<Pi/Nsector || fabs(2.*Pi-fabs(phi-theta_tmp))<Pi/Nsector) ti=t; // gives tile #
73  }
74 
75  double thetaij = MidTile[layer]+2.*ti*Pi/Nsector;
76  int ClosestStrip=0;
77  if(layer%2==0)
78  ClosestStrip = (int) (floor( (-DZ+x*(cos(thetaij)*tan(alpha)+sin(thetaij))+y*(sin(thetaij)*tan(alpha)-cos(thetaij)))/pitch) +
79  floor(2.0*((-DZ+x*(cos(thetaij)*tan(alpha)+sin(thetaij)) + y*(sin(thetaij)*tan(alpha)-cos(thetaij)))/pitch -
80  floor((-DZ+x*(cos(thetaij)*tan(alpha)+sin(thetaij)) + y*(sin(thetaij)*tan(alpha)-cos(thetaij)))/pitch))));
81 
82  if(layer%2==1)
83  ClosestStrip = (int) (floor( (-DZ+x*(cos(thetaij)*tan(alpha)-sin(thetaij))+y*(sin(thetaij)*tan(alpha)+cos(thetaij)))/pitch) +
84  floor(2.0*((-DZ+x*(cos(thetaij)*tan(alpha)-sin(thetaij))+y*(sin(thetaij)*tan(alpha)+cos(thetaij)))/pitch -
85  floor((-DZ+x*(cos(thetaij)*tan(alpha)-sin(thetaij))+y*(sin(thetaij)*tan(alpha)+cos(thetaij)))/pitch))));
86 
87  int IsOK=1;
88 
89  // now check if the position is in the acceptance of the detector:
90  if(ClosestStrip<0 || ClosestStrip>Nstrips) IsOK = 0;
91  if(x*cos(thetaij)+y*sin(thetaij)< Rmin || x*cos(thetaij)+y*sin(thetaij)>Rmax)
92  {
93  // cout << " Outside Acceptance " << endl;
94  IsOK = 0;
95  }
96  if(x*cos(thetaij)+y*sin(thetaij)<(Rint+DZ) && x*cos(thetaij)+y*sin(thetaij)>(Rint-DZ)) IsOK = 0; // new ("inner" dead zones)
97  if(IsOK) return ClosestStrip;
98  else return -1;
99 
100 }
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
void fill_infos()
Definition: fst_strip.cc:9
vector< double > Z0
Definition: fst_strip.h:20
int Nsector
Definition: fst_strip.h:13
double DZ
Definition: fst_strip.h:14
double Rint
Definition: fst_strip.h:16
vector< double > MidTile
Definition: fst_strip.h:22
double Pi
Definition: fst_strip.h:9
double Rmax
Definition: fst_strip.h:17
double Z_1stlayer
Definition: fst_strip.h:18
double alpha
Definition: fst_strip.h:7
double pitch
Definition: fst_strip.h:8
int FindStrip(int layer, int sector, double x, double y, double z)
Definition: fst_strip.cc:53
double Rmin
Definition: fst_strip.h:15
double intersuperlayer
Definition: fst_strip.h:12
double interlayer
Definition: fst_strip.h:11
int Nstrips
Definition: fst_strip.h:23