]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliLegoGenerator.cxx
Containers definition
[u/mrichter/AliRoot.git] / STEER / AliLegoGenerator.cxx
CommitLineData
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 18Revision 1.2 2000/07/13 16:19:09 fca
19Mainly coding conventions + some small bug fixes
20
ef42d733 21Revision 1.1 2000/07/12 08:56:25 fca
22Coding convention correction and warning removal
23
8918e700 24Revision 1.16 2000/05/26 08:35:03 fca
25Move the check on z after z has been retrieved
26
27Revision 1.15 2000/05/16 13:10:40 fca
28New method IsNewTrack and fix for a problem in Father-Daughter relations
29
30Revision 1.14 2000/04/27 10:38:21 fca
31Correct termination of Lego Run and introduce Lego getter in AliRun
32
33Revision 1.13 2000/04/26 10:17:31 fca
34Changes in Lego for G4 compatibility
35
36Revision 1.12 2000/04/07 11:12:33 fca
37G4 compatibility changes
38
39Revision 1.11 2000/03/22 13:42:26 fca
40SetGenerator does not replace an existing generator, ResetGenerator does
41
42Revision 1.10 2000/02/23 16:25:22 fca
43AliVMC and AliGeant3 classes introduced
44ReadEuclid moved from AliRun to AliModule
45
46Revision 1.9 1999/12/03 10:54:01 fca
47Fix lego summary
48
49Revision 1.8 1999/10/01 09:54:33 fca
50Correct logics for Lego StepManager
51
52Revision 1.7 1999/09/29 09:24:29 fca
53Introduction of the Copyright and cvs Log
8918e700 54*/
55
56#include "AliLegoGenerator.h"
57#include "AliRun.h"
58
59ClassImp(AliLegoGenerator)
60
61//___________________________________________
34915916 62
63AliLegoGenerator::AliLegoGenerator()
64{
65 //
66 // Default Constructor
67 //
68 SetName("Lego");
69
70 fCoor1Bin = fCoor2Bin = -1;
71 fCurCoor1 = fCurCoor2 = 0;
72}
73
74AliLegoGenerator::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//___________________________________________
91void 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//___________________________________________
143Float_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