]>
Commit | Line | Data |
---|---|---|
8918e700 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
acd84897 | 16 | /* $Id$ */ |
8918e700 | 17 | |
116cbefd | 18 | //------------------------------------------------------------------------ |
19 | // | |
20 | // Generic Lego generator code | |
21 | // | |
22 | //------------------------------------------------------------------------ | |
23 | ||
8918e700 | 24 | #include "AliLegoGenerator.h" |
25 | #include "AliRun.h" | |
26 | ||
27 | ClassImp(AliLegoGenerator) | |
28 | ||
e2afb3b6 | 29 | //_______________________________________________________________________ |
30 | AliLegoGenerator::AliLegoGenerator(): | |
31 | fRadMin(0), | |
32 | fRadMax(0), | |
33 | fZMax(0), | |
34 | fNCoor1(0), | |
35 | fNCoor2(0), | |
36 | fCoor1Min(0), | |
37 | fCoor1Max(0), | |
38 | fCoor2Min(0), | |
39 | fCoor2Max(0), | |
40 | fCoor1Bin(-1), | |
41 | fCoor2Bin(-1), | |
42 | fCurCoor1(0), | |
43 | fCurCoor2(0) | |
34915916 | 44 | { |
45 | // | |
46 | // Default Constructor | |
47 | // | |
48 | SetName("Lego"); | |
34915916 | 49 | } |
50 | ||
e2afb3b6 | 51 | //_______________________________________________________________________ |
34915916 | 52 | AliLegoGenerator::AliLegoGenerator(Int_t nc1, Float_t c1min, |
e2afb3b6 | 53 | Float_t c1max, Int_t nc2, |
54 | Float_t c2min, Float_t c2max, | |
55 | Float_t rmin, Float_t rmax, Float_t zmax): | |
56 | AliGenerator(0), | |
57 | fRadMin(rmin), | |
58 | fRadMax(rmax), | |
59 | fZMax(zmax), | |
60 | fNCoor1(nc1), | |
61 | fNCoor2(nc2), | |
62 | fCoor1Min(0), | |
63 | fCoor1Max(0), | |
64 | fCoor2Min(0), | |
65 | fCoor2Max(0), | |
66 | fCoor1Bin(nc1), | |
67 | fCoor2Bin(-1), | |
68 | fCurCoor1(0), | |
69 | fCurCoor2(0) | |
8918e700 | 70 | { |
ef42d733 | 71 | // |
72 | // Standard generator for Lego rays | |
73 | // | |
e2afb3b6 | 74 | SetName("Lego"); |
34915916 | 75 | SetCoor1Range(nc1, c1min, c1max); |
76 | SetCoor2Range(nc2, c2min, c2max); | |
8918e700 | 77 | } |
78 | ||
e2afb3b6 | 79 | //_______________________________________________________________________ |
8918e700 | 80 | void AliLegoGenerator::Generate() |
81 | { | |
e2afb3b6 | 82 | // Create a geantino with kinematics corresponding to the current bins |
83 | // Here: Coor1 = theta | |
84 | // Coor2 = phi. | |
85 | ||
8918e700 | 86 | // |
87 | // Rootinos are 0 | |
88 | const Int_t kMpart = 0; | |
89 | Float_t orig[3], pmom[3]; | |
90 | Float_t t, cost, sint, cosp, sinp; | |
34915916 | 91 | if (fCoor1Bin==-1) fCoor1Bin=fNCoor1; |
8918e700 | 92 | // Prepare for next step |
34915916 | 93 | if(fCoor1Bin>=fNCoor1-1) |
94 | if(fCoor2Bin>=fNCoor2-1) { | |
8918e700 | 95 | Warning("Generate","End of Lego Generation"); |
96 | return; | |
97 | } else { | |
34915916 | 98 | fCoor2Bin++; |
99 | printf("Generating rays in phi bin:%d\n",fCoor2Bin); | |
100 | fCoor1Bin=0; | |
101 | } else fCoor1Bin++; | |
102 | ||
103 | fCurCoor1 = (fCoor1Min+(fCoor1Bin+0.5)*(fCoor1Max-fCoor1Min)/fNCoor1); | |
104 | fCurCoor2 = (fCoor2Min+(fCoor2Bin+0.5)*(fCoor2Max-fCoor2Min)/fNCoor2); | |
105 | cost = TMath::Cos(fCurCoor1 * TMath::Pi()/180.); | |
106 | sint = TMath::Sin(fCurCoor1 * TMath::Pi()/180.); | |
107 | cosp = TMath::Cos(fCurCoor2 * TMath::Pi()/180.); | |
108 | sinp = TMath::Sin(fCurCoor2 * TMath::Pi()/180.); | |
8918e700 | 109 | |
110 | pmom[0] = cosp*sint; | |
111 | pmom[1] = sinp*sint; | |
112 | pmom[2] = cost; | |
113 | ||
114 | // --- Where to start | |
115 | orig[0] = orig[1] = orig[2] = 0; | |
116 | Float_t dalicz = 3000; | |
117 | if (fRadMin > 0) { | |
34915916 | 118 | t = PropagateCylinder(orig,pmom,fRadMin,dalicz); |
119 | orig[0] = pmom[0]*t; | |
120 | orig[1] = pmom[1]*t; | |
121 | orig[2] = pmom[2]*t; | |
122 | if (TMath::Abs(orig[2]) > fZMax) return; | |
8918e700 | 123 | } |
124 | ||
125 | Float_t polar[3]={0.,0.,0.}; | |
126 | Int_t ntr; | |
9e1a0ddb | 127 | gAlice->SetTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr); |
34915916 | 128 | |
8918e700 | 129 | } |
130 | ||
e2afb3b6 | 131 | //_______________________________________________________________________ |
132 | Float_t AliLegoGenerator::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, | |
133 | Float_t z) | |
8918e700 | 134 | { |
e2afb3b6 | 135 | // |
136 | // Propagate to cylinder from inside | |
137 | // | |
8918e700 | 138 | Double_t hnorm, sz, t, t1, t2, t3, sr; |
139 | Double_t d[3]; | |
140 | const Float_t kSmall = 1e-8; | |
141 | const Float_t kSmall2 = kSmall*kSmall; | |
142 | ||
143 | // ---> Find intesection with Z planes | |
144 | d[0] = v[0]; | |
145 | d[1] = v[1]; | |
146 | d[2] = v[2]; | |
147 | hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2])); | |
148 | d[0] *= hnorm; | |
149 | d[1] *= hnorm; | |
150 | d[2] *= hnorm; | |
151 | if (d[2] > kSmall) sz = (z-x[2])/d[2]; | |
152 | else if (d[2] < -kSmall) sz = -(z+x[2])/d[2]; | |
153 | else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection | |
154 | ||
155 | // ---> Intersection with cylinders | |
156 | // Intersection point (x,y,z) | |
157 | // (x,y,z) is on track : x=X(1)+t*D(1) | |
158 | // y=X(2)+t*D(2) | |
159 | // z=X(3)+t*D(3) | |
160 | // (x,y,z) is on cylinder : x**2 + y**2 = R**2 | |
161 | // | |
162 | // (D(1)**2+D(2)**2)*t**2 | |
163 | // +2.*(X(1)*D(1)+X(2)*D(2))*t | |
164 | // +X(1)**2+X(2)**2-R**2=0 | |
165 | // ---> Solve second degree equation | |
166 | t1 = d[0]*d[0] + d[1]*d[1]; | |
167 | if (t1 <= kSmall2) { | |
168 | t = sz; // ---> Track parallel to the z-axis, take distance to planes | |
169 | } else { | |
170 | t2 = x[0]*d[0] + x[1]*d[1]; | |
171 | t3 = x[0]*x[0] + x[1]*x[1]; | |
172 | // ---> It should be positive, but there may be numerical problems | |
34915916 | 173 | sr = (-t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1; |
8918e700 | 174 | // ---> Find minimum distance between planes and cylinder |
175 | t = TMath::Min(sz,sr); | |
176 | } | |
177 | return t; | |
178 | } | |
179 | ||
34915916 | 180 |