]>
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 | ||
16 | /* | |
17 | $Log$ | |
34915916 | 18 | Revision 1.2 2000/07/13 16:19:09 fca |
19 | Mainly coding conventions + some small bug fixes | |
20 | ||
ef42d733 | 21 | Revision 1.1 2000/07/12 08:56:25 fca |
22 | Coding convention correction and warning removal | |
23 | ||
8918e700 | 24 | Revision 1.16 2000/05/26 08:35:03 fca |
25 | Move the check on z after z has been retrieved | |
26 | ||
27 | Revision 1.15 2000/05/16 13:10:40 fca | |
28 | New method IsNewTrack and fix for a problem in Father-Daughter relations | |
29 | ||
30 | Revision 1.14 2000/04/27 10:38:21 fca | |
31 | Correct termination of Lego Run and introduce Lego getter in AliRun | |
32 | ||
33 | Revision 1.13 2000/04/26 10:17:31 fca | |
34 | Changes in Lego for G4 compatibility | |
35 | ||
36 | Revision 1.12 2000/04/07 11:12:33 fca | |
37 | G4 compatibility changes | |
38 | ||
39 | Revision 1.11 2000/03/22 13:42:26 fca | |
40 | SetGenerator does not replace an existing generator, ResetGenerator does | |
41 | ||
42 | Revision 1.10 2000/02/23 16:25:22 fca | |
43 | AliVMC and AliGeant3 classes introduced | |
44 | ReadEuclid moved from AliRun to AliModule | |
45 | ||
46 | Revision 1.9 1999/12/03 10:54:01 fca | |
47 | Fix lego summary | |
48 | ||
49 | Revision 1.8 1999/10/01 09:54:33 fca | |
50 | Correct logics for Lego StepManager | |
51 | ||
52 | Revision 1.7 1999/09/29 09:24:29 fca | |
53 | Introduction of the Copyright and cvs Log | |
8918e700 | 54 | */ |
55 | ||
56 | #include "AliLegoGenerator.h" | |
57 | #include "AliRun.h" | |
58 | ||
59 | ClassImp(AliLegoGenerator) | |
60 | ||
61 | //___________________________________________ | |
34915916 | 62 | |
63 | AliLegoGenerator::AliLegoGenerator() | |
64 | { | |
65 | // | |
66 | // Default Constructor | |
67 | // | |
68 | SetName("Lego"); | |
69 | ||
70 | fCoor1Bin = fCoor2Bin = -1; | |
71 | fCurCoor1 = fCurCoor2 = 0; | |
72 | } | |
73 | ||
74 | AliLegoGenerator::AliLegoGenerator(Int_t nc1, Float_t c1min, | |
75 | Float_t c1max, Int_t nc2, | |
76 | Float_t c2min, Float_t c2max, | |
8918e700 | 77 | Float_t rmin, Float_t rmax, Float_t zmax) : |
34915916 | 78 | AliGenerator(0), fRadMin(rmin), fRadMax(rmax), fZMax(zmax), fNCoor1(nc1), |
79 | fNCoor2(nc2), fCoor1Bin(nc1), fCoor2Bin(-1), fCurCoor1(0), fCurCoor2(0) | |
8918e700 | 80 | |
81 | { | |
ef42d733 | 82 | // |
83 | // Standard generator for Lego rays | |
84 | // | |
34915916 | 85 | SetCoor1Range(nc1, c1min, c1max); |
86 | SetCoor2Range(nc2, c2min, c2max); | |
8918e700 | 87 | SetName("Lego"); |
88 | } | |
89 | ||
8918e700 | 90 | //___________________________________________ |
91 | void AliLegoGenerator::Generate() | |
92 | { | |
34915916 | 93 | // Create a geantino with kinematics corresponding to the current bins |
94 | // Here: Coor1 = theta | |
95 | // Coor2 = phi. | |
8918e700 | 96 | |
97 | // | |
98 | // Rootinos are 0 | |
99 | const Int_t kMpart = 0; | |
100 | Float_t orig[3], pmom[3]; | |
101 | Float_t t, cost, sint, cosp, sinp; | |
34915916 | 102 | if (fCoor1Bin==-1) fCoor1Bin=fNCoor1; |
8918e700 | 103 | // Prepare for next step |
34915916 | 104 | if(fCoor1Bin>=fNCoor1-1) |
105 | if(fCoor2Bin>=fNCoor2-1) { | |
8918e700 | 106 | Warning("Generate","End of Lego Generation"); |
107 | return; | |
108 | } else { | |
34915916 | 109 | fCoor2Bin++; |
110 | printf("Generating rays in phi bin:%d\n",fCoor2Bin); | |
111 | fCoor1Bin=0; | |
112 | } else fCoor1Bin++; | |
113 | ||
114 | fCurCoor1 = (fCoor1Min+(fCoor1Bin+0.5)*(fCoor1Max-fCoor1Min)/fNCoor1); | |
115 | fCurCoor2 = (fCoor2Min+(fCoor2Bin+0.5)*(fCoor2Max-fCoor2Min)/fNCoor2); | |
116 | cost = TMath::Cos(fCurCoor1 * TMath::Pi()/180.); | |
117 | sint = TMath::Sin(fCurCoor1 * TMath::Pi()/180.); | |
118 | cosp = TMath::Cos(fCurCoor2 * TMath::Pi()/180.); | |
119 | sinp = TMath::Sin(fCurCoor2 * TMath::Pi()/180.); | |
8918e700 | 120 | |
121 | pmom[0] = cosp*sint; | |
122 | pmom[1] = sinp*sint; | |
123 | pmom[2] = cost; | |
124 | ||
125 | // --- Where to start | |
126 | orig[0] = orig[1] = orig[2] = 0; | |
127 | Float_t dalicz = 3000; | |
128 | if (fRadMin > 0) { | |
34915916 | 129 | t = PropagateCylinder(orig,pmom,fRadMin,dalicz); |
130 | orig[0] = pmom[0]*t; | |
131 | orig[1] = pmom[1]*t; | |
132 | orig[2] = pmom[2]*t; | |
133 | if (TMath::Abs(orig[2]) > fZMax) return; | |
8918e700 | 134 | } |
135 | ||
136 | Float_t polar[3]={0.,0.,0.}; | |
137 | Int_t ntr; | |
138 | gAlice->SetTrack(1, 0, kMpart, pmom, orig, polar, 0, "LEGO ray", ntr); | |
34915916 | 139 | |
8918e700 | 140 | } |
141 | ||
142 | //___________________________________________ | |
143 | Float_t AliLegoGenerator::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z) | |
144 | { | |
145 | // Propagate to cylinder from inside | |
146 | ||
147 | Double_t hnorm, sz, t, t1, t2, t3, sr; | |
148 | Double_t d[3]; | |
149 | const Float_t kSmall = 1e-8; | |
150 | const Float_t kSmall2 = kSmall*kSmall; | |
151 | ||
152 | // ---> Find intesection with Z planes | |
153 | d[0] = v[0]; | |
154 | d[1] = v[1]; | |
155 | d[2] = v[2]; | |
156 | hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2])); | |
157 | d[0] *= hnorm; | |
158 | d[1] *= hnorm; | |
159 | d[2] *= hnorm; | |
160 | if (d[2] > kSmall) sz = (z-x[2])/d[2]; | |
161 | else if (d[2] < -kSmall) sz = -(z+x[2])/d[2]; | |
162 | else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection | |
163 | ||
164 | // ---> Intersection with cylinders | |
165 | // Intersection point (x,y,z) | |
166 | // (x,y,z) is on track : x=X(1)+t*D(1) | |
167 | // y=X(2)+t*D(2) | |
168 | // z=X(3)+t*D(3) | |
169 | // (x,y,z) is on cylinder : x**2 + y**2 = R**2 | |
170 | // | |
171 | // (D(1)**2+D(2)**2)*t**2 | |
172 | // +2.*(X(1)*D(1)+X(2)*D(2))*t | |
173 | // +X(1)**2+X(2)**2-R**2=0 | |
174 | // ---> Solve second degree equation | |
175 | t1 = d[0]*d[0] + d[1]*d[1]; | |
176 | if (t1 <= kSmall2) { | |
177 | t = sz; // ---> Track parallel to the z-axis, take distance to planes | |
178 | } else { | |
179 | t2 = x[0]*d[0] + x[1]*d[1]; | |
180 | t3 = x[0]*x[0] + x[1]*x[1]; | |
181 | // ---> It should be positive, but there may be numerical problems | |
34915916 | 182 | sr = (-t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1; |
8918e700 | 183 | // ---> Find minimum distance between planes and cylinder |
184 | t = TMath::Min(sz,sr); | |
185 | } | |
186 | return t; | |
187 | } | |
188 | ||
34915916 | 189 |