| [807] | 1 | // %%%%%%%%%%%%%
|
|---|
| 2 | // gemc headers
|
|---|
| 3 | // %%%%%%%%%%%%%
|
|---|
| 4 | #include "bst_strip.h"
|
|---|
| 5 |
|
|---|
| 6 | #include <iostream>
|
|---|
| 7 | #include <cmath>
|
|---|
| 8 | #include <cstdlib>
|
|---|
| 9 |
|
|---|
| 10 | void bst_strip::fill_infos()
|
|---|
| 11 | {
|
|---|
| 12 | // all dimensions are in mm
|
|---|
| 13 |
|
|---|
| 14 | Pi = 3.14159265358;
|
|---|
| 15 | interlayer = 2.75; // distance between 2 layers of a superlayer
|
|---|
| 16 |
|
|---|
| 17 | alpha = 1.5*Pi/180; // angle of the strips
|
|---|
| 18 | pitch = 0.150; // pitch of the strips
|
|---|
| 19 |
|
|---|
| 20 | // number of sectors for each layer
|
|---|
| 21 | Nsector.push_back(8); Nsector.push_back(8);
|
|---|
| 22 | Nsector.push_back(12); Nsector.push_back(12);
|
|---|
| 23 | Nsector.push_back(18); Nsector.push_back(18);
|
|---|
| 24 | Nsector.push_back(24); Nsector.push_back(24);
|
|---|
| 25 |
|
|---|
| 26 | // number of cards by sector for each layer
|
|---|
| 27 | Ncards.push_back(1); Ncards.push_back(1);
|
|---|
| 28 | Ncards.push_back(2); Ncards.push_back(2);
|
|---|
| 29 | Ncards.push_back(3); Ncards.push_back(3);
|
|---|
| 30 | Ncards.push_back(3); Ncards.push_back(3);
|
|---|
| 31 |
|
|---|
| 32 | // z of the upstream part of the layer
|
|---|
| 33 | Z0.push_back(-39.219); Z0.push_back(-39.219);
|
|---|
| 34 | Z0.push_back(-111.319); Z0.push_back(-111.319);
|
|---|
| 35 | Z0.push_back(-164.787); Z0.push_back(-164.787);
|
|---|
| 36 | Z0.push_back(-107.070); Z0.push_back(-107.070);
|
|---|
| 37 |
|
|---|
| 38 | // radii of layers
|
|---|
| 39 | R.push_back(101.129/2); R.push_back(R[0]+interlayer);
|
|---|
| 40 | R.push_back(156.853/2); R.push_back(R[2]+interlayer);
|
|---|
| 41 | R.push_back(238.869/2); R.push_back(R[4]+interlayer);
|
|---|
| 42 | R.push_back(320.268/2); R.push_back(R[6]+interlayer);
|
|---|
| 43 |
|
|---|
| 44 | // mid angle of the sector
|
|---|
| 45 | MidTile.push_back(0); MidTile.push_back(0);
|
|---|
| 46 | MidTile.push_back(0); MidTile.push_back(0);
|
|---|
| 47 | MidTile.push_back(Pi/18); MidTile.push_back(Pi/18);
|
|---|
| 48 | MidTile.push_back(0); MidTile.push_back(0);
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | DZ_inLength = 0.934; // size of the band of dead zones all around in the length of the card
|
|---|
| 52 | DZ_inWidth = 0.934; // size of the band of dead zones all around in the width of the card
|
|---|
| 53 | CardLength = 111.625; // length of 1 card
|
|---|
| 54 | CardWidth = 41.7; // width 1 card
|
|---|
| 55 |
|
|---|
| 56 | // Number of strips
|
|---|
| 57 | NstripsZ = (int) floor((CardWidth-2.0*DZ_inLength-(CardLength-2*DZ_inWidth)*tan(alpha))*cos(alpha)/pitch);
|
|---|
| 58 | Nstrips = (int) floor((CardWidth-2.0*DZ_inLength)/pitch);
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | void bst_strip::FindCard(int layer, double Z)
|
|---|
| 64 | {
|
|---|
| 65 | if(Z>Z0[layer] && Z<Z0[layer]+Ncards[layer]*CardLength)
|
|---|
| 66 | {
|
|---|
| 67 | // get the card index
|
|---|
| 68 | nCard = (int) floor((Z-Z0[layer])/CardLength);
|
|---|
| 69 |
|
|---|
| 70 | // redefine z to the global coordinate on the first card.
|
|---|
| 71 | // If it's the middle card z becomes the distance to the right edge.
|
|---|
| 72 | if((nCard%2)==0) z = Z - nCard*CardLength;
|
|---|
| 73 | if((nCard%2)==1) z = Z0[layer] + (nCard+1)*CardLength - Z + Z0[layer];
|
|---|
| 74 |
|
|---|
| 75 | // now hit is in the 1st card of the tile! let's check it
|
|---|
| 76 | if(z<Z0[layer] || z>Z0[layer]+CardLength)
|
|---|
| 77 | {
|
|---|
| 78 | cout << " Warning: z not within first card. This should never happen! z = " << z << ", card = " << nCard << endl;
|
|---|
| 79 | exit(0);
|
|---|
| 80 | }
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | int bst_strip::FindStripZ(int layer, int sector, double X, double Y)
|
|---|
| 86 | {
|
|---|
| 87 | x = X;
|
|---|
| 88 | y = Y;
|
|---|
| 89 |
|
|---|
| 90 | double mindist = 999.; // min distance between the points and strips
|
|---|
| 91 | double dist = 999.; // distance to current strip
|
|---|
| 92 | int ClosestStrip = -1; // number of the closest strip
|
|---|
| 93 |
|
|---|
| 94 | int IsOK = 0;
|
|---|
| 95 | const int MAXNSTRIP = 1024;
|
|---|
| 96 | if(NstripsZ > MAXNSTRIP)
|
|---|
| 97 | {
|
|---|
| 98 | cout << " Warning: number of strips > 1024. Exiting. " << endl;
|
|---|
| 99 | exit(0);
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | double Px[MAXNSTRIP], Py[MAXNSTRIP], Pz[MAXNSTRIP];
|
|---|
| 103 | double Pxp[MAXNSTRIP], Pyp[MAXNSTRIP], Pzp[MAXNSTRIP];
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | for(int k=0; k<NstripsZ; k++)
|
|---|
| 107 | {
|
|---|
| 108 | Px[k] = (R[layer]/cos(0.5*(CardWidth/R[layer])))*cos(MidTile[layer] +
|
|---|
| 109 | 2.0*sector*Pi/Nsector[layer] + 0.5*CardWidth/R[layer]) + DZ_inLength*sin(MidTile[layer] +
|
|---|
| 110 | 2.0*sector*Pi/Nsector[layer]) + (pitch*k/cos(alpha))*sin(MidTile[layer] +
|
|---|
| 111 | 2.0*sector*Pi/Nsector[layer]);
|
|---|
| 112 | Py[k] = (R[layer]/cos(0.5*(CardWidth/R[layer])))*sin(MidTile[layer] +
|
|---|
| 113 | 2.0*sector*Pi/Nsector[layer] + 0.5*CardWidth/R[layer]) - DZ_inLength*cos(MidTile[layer] +
|
|---|
| 114 | 2.0*sector*Pi/Nsector[layer]) - (pitch*k/cos(alpha))*cos(MidTile[layer] +
|
|---|
| 115 | 2.0*sector*Pi/Nsector[layer]);
|
|---|
| 116 | Pz[k] = Z0[layer]+DZ_inWidth;
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | Pxp[k] = (R[layer]/cos(0.5*(CardWidth/R[layer])))*cos(MidTile[layer]
|
|---|
| 120 | + 2.0*sector*Pi/Nsector[layer] - 0.5*CardWidth/R[layer])-DZ_inLength*sin(MidTile[layer]
|
|---|
| 121 | + 2.0*sector*Pi/Nsector[layer]) - (pitch*k/cos(alpha))*sin(MidTile[layer]
|
|---|
| 122 | + 2.0*sector*Pi/Nsector[layer]);
|
|---|
| 123 | Pyp[k] = (R[layer]/cos(0.5*(CardWidth/R[layer])))*sin(MidTile[layer]
|
|---|
| 124 | + 2.0*sector*Pi/Nsector[layer] - 0.5*CardWidth/R[layer])+DZ_inLength*cos(MidTile[layer]
|
|---|
| 125 | + 2.0*sector*Pi/Nsector[layer]) + (pitch*k/cos(alpha))*cos(MidTile[layer]
|
|---|
| 126 | + 2.0*sector*Pi/Nsector[layer]);
|
|---|
| 127 | Pzp[k] = Z0[layer]+DZ_inWidth;
|
|---|
| 128 |
|
|---|
| 129 | // W layer
|
|---|
| 130 | if((layer%2)==0)
|
|---|
| 131 | {
|
|---|
| 132 | dist = fabs( - sin(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(alpha)*x
|
|---|
| 133 | + cos(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(alpha)*y
|
|---|
| 134 | + sin(alpha)*z
|
|---|
| 135 | + sin(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(alpha)*Px[k]
|
|---|
| 136 | - cos(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(alpha)*Py[k]
|
|---|
| 137 | - sin(alpha)*Pz[k]);
|
|---|
| 138 |
|
|---|
| 139 | if(dist<mindist)
|
|---|
| 140 | {
|
|---|
| 141 | mindist = dist;
|
|---|
| 142 | ClosestStrip = k;
|
|---|
| 143 | }
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | // V layer
|
|---|
| 147 | if((layer%2)==1)
|
|---|
| 148 | {
|
|---|
| 149 | dist = fabs( - sin(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(-alpha)*x
|
|---|
| 150 | + cos(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(-alpha)*y
|
|---|
| 151 | + sin(-alpha)*z
|
|---|
| 152 | + sin(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(-alpha)*Pxp[k]
|
|---|
| 153 | - cos(MidTile[layer] + sector*2.0*Pi/Nsector[layer])*cos(-alpha)*Pyp[k]
|
|---|
| 154 | - sin(-alpha)*Pzp[k]);
|
|---|
| 155 |
|
|---|
| 156 | if(dist<mindist)
|
|---|
| 157 | {
|
|---|
| 158 | mindist = dist;
|
|---|
| 159 | ClosestStrip = k;
|
|---|
| 160 | }
|
|---|
| 161 | }
|
|---|
| 162 | }
|
|---|
| 163 | if(mindist<pitch/2. && z>Z0[layer]+DZ_inWidth && z<Z0[layer]+CardLength-DZ_inWidth) IsOK = 1;
|
|---|
| 164 | else IsOK = 0;
|
|---|
| 165 |
|
|---|
| 166 | if(IsOK) return ClosestStrip;
|
|---|
| 167 | else return -1;
|
|---|
| 168 |
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | int bst_strip::FindStrip(int layer, int sector, double X, double Y, double Z)
|
|---|
| 174 | {
|
|---|
| 175 | x = X;
|
|---|
| 176 | y = Y;
|
|---|
| 177 | z = Z;
|
|---|
| 178 |
|
|---|
| 179 | double mindist = 999.; // min distance between the points and strips
|
|---|
| 180 | double dist = 999.; // distance to current strip
|
|---|
| 181 | int ClosestStrip = -1; // number of the closest strip
|
|---|
| 182 | int IsOK = 0;
|
|---|
| 183 | const int MAXNSTRIP = 1024;
|
|---|
| 184 |
|
|---|
| 185 | if(Nstrips > MAXNSTRIP)
|
|---|
| 186 | {
|
|---|
| 187 | cout << " Warning: number of strips > 1024. Exiting. " << endl;
|
|---|
| 188 | exit(0);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | double Px[MAXNSTRIP], Py[MAXNSTRIP], Pz[MAXNSTRIP];
|
|---|
| 192 | double Pxp[MAXNSTRIP], Pyp[MAXNSTRIP], Pzp[MAXNSTRIP];
|
|---|
| 193 | double alpha_k;
|
|---|
| 194 |
|
|---|
| 195 | // particle is in the z-acceptance
|
|---|
| 196 | if(z>Z0[layer]+DZ_inWidth && z<Z0[layer]+Ncards[layer]*CardLength-DZ_inWidth)
|
|---|
| 197 | {
|
|---|
| 198 |
|
|---|
| 199 | for(int k=0; k<Nstrips; k++)
|
|---|
| 200 | {
|
|---|
| 201 | alpha_k = k/((float)(Nstrips-1))*alpha;
|
|---|
| 202 | Px[k] = (R[layer]/cos(atan(0.5*(CardWidth/R[layer]))))*cos(MidTile[layer] +
|
|---|
| 203 | 2.0*sector*Pi/Nsector[layer]+atan(0.5*CardWidth/R[layer]))+DZ_inLength*sin(MidTile[layer] +
|
|---|
| 204 | 2.0*sector*Pi/Nsector[layer])+(pitch*k)*sin(MidTile[layer]+sector*2.0*Pi/Nsector[layer]);
|
|---|
| 205 | Py[k] = (R[layer]/cos(atan(0.5*(CardWidth/R[layer]))))*sin(MidTile[layer] +
|
|---|
| 206 | 2.0*sector*Pi/Nsector[layer]+atan(0.5*CardWidth/R[layer]))-DZ_inLength*cos(MidTile[layer] +
|
|---|
| 207 | 2.0*sector*Pi/Nsector[layer])-(pitch*k)*cos(MidTile[layer]+sector*2.*Pi/Nsector[layer]);
|
|---|
| 208 | Pz[k] = Z0[layer]+DZ_inWidth;
|
|---|
| 209 |
|
|---|
| 210 | Pxp[k] = (R[layer]/cos(atan(0.5*(CardWidth/R[layer]))))*cos(MidTile[layer] +
|
|---|
| 211 | 2.0*sector*Pi/Nsector[layer]-atan(0.5*CardWidth/R[layer]))-DZ_inLength*sin(MidTile[layer] +
|
|---|
| 212 | 2.0*sector*Pi/Nsector[layer])-(pitch*k)*sin(MidTile[layer]+sector*2.*Pi/Nsector[layer]);
|
|---|
| 213 | Pyp[k] = (R[layer]/cos(atan(0.5*(CardWidth/R[layer]))))*sin(MidTile[layer] +
|
|---|
| 214 | 2.0*sector*Pi/Nsector[layer]-atan(0.5*CardWidth/R[layer]))+DZ_inLength*cos(MidTile[layer] +
|
|---|
| 215 | 2.0*sector*Pi/Nsector[layer])+(pitch*k)*cos(MidTile[layer]+sector*2.*Pi/Nsector[layer]);
|
|---|
| 216 | Pzp[k] = Z0[layer]+DZ_inWidth;
|
|---|
| 217 |
|
|---|
| 218 | if((layer%2)==0)
|
|---|
| 219 | {
|
|---|
| 220 | dist = fabs(-sin(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(alpha_k)*x +
|
|---|
| 221 | cos(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(alpha_k)*y +
|
|---|
| 222 | sin(alpha_k)*z +
|
|---|
| 223 | sin(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(alpha_k)*Px[k] -
|
|---|
| 224 | cos(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(alpha_k)*Py[k] -
|
|---|
| 225 | sin(alpha_k)*Pz[k]);
|
|---|
| 226 | if(dist<mindist)
|
|---|
| 227 | {
|
|---|
| 228 | mindist = dist;
|
|---|
| 229 | ClosestStrip = k; // record strip number
|
|---|
| 230 | }
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | if((layer%2)==1)
|
|---|
| 234 | {
|
|---|
| 235 | dist = fabs(-sin(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(-alpha_k)*x +
|
|---|
| 236 | cos(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(-alpha_k)*y +
|
|---|
| 237 | sin(-alpha_k)*z +
|
|---|
| 238 | sin(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(-alpha_k)*Pxp[k] -
|
|---|
| 239 | cos(MidTile[layer]+sector*2.0*Pi/Nsector[layer])*cos(-alpha_k)*Pyp[k] -
|
|---|
| 240 | sin(-alpha_k)*Pzp[k]);
|
|---|
| 241 | if(dist<mindist)
|
|---|
| 242 | {
|
|---|
| 243 | mindist = dist;
|
|---|
| 244 | ClosestStrip = k; // record strip number
|
|---|
| 245 | }
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 | if(mindist < (pitch+(Ncards[layer]*CardLength-2.*DZ_inWidth)*alpha/(Nstrips-1)*(1.+tan(alpha)*tan(alpha)))/2. &&
|
|---|
| 249 | z>Z0[layer]+DZ_inWidth &&
|
|---|
| 250 | z<Z0[layer]+Ncards[layer]*CardLength-DZ_inWidth &&
|
|---|
| 251 | sqrt(x*x+y*y)<R[layer]/cos(atan((0.5*CardWidth-DZ_inLength)/R[layer]))) IsOK = 1;
|
|---|
| 252 | else IsOK = 0;
|
|---|
| 253 | }
|
|---|
| 254 | else
|
|---|
| 255 | {
|
|---|
| 256 | // particle not in the z-acceptance
|
|---|
| 257 | IsOK = 0;
|
|---|
| 258 | ClosestStrip = -1;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | if(IsOK) return ClosestStrip;
|
|---|
| 262 | else return -1;
|
|---|
| 263 |
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|