source: trunk/examples/novice/gemc/src/fst_strip.cc @ 1309

Last change on this file since 1309 was 807, checked in by garnier, 16 years ago

update

File size: 3.5 KB
Line 
1// %%%%%%%%%%%%%
2// gemc headers
3// %%%%%%%%%%%%%
4#include "fst_strip.h"
5
6#include <iostream>
7#include <cmath>
8
9void fst_strip::fill_infos()
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 = 15.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 
22 DZ = 0.934;                    // size of the band of dead zones
23 Rmin = 19.029;                 // inner radius of disks
24 Rmax = (Rmin+45.419+123.552);  // outer radius of disks
25 Z_1stlayer = 238.065;          // 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
53int 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 
97  if(IsOK) return ClosestStrip;
98  else return -1;
99 
100
101}
102
103
104
105
106
107
108
109
110
111
112
Note: See TracBrowser for help on using the repository browser.