1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.8 1999/10/01 09:54:33 fca
19 Correct logics for Lego StepManager
21 Revision 1.7 1999/09/29 09:24:29 fca
22 Introduction of the Copyright and cvs Log
26 //////////////////////////////////////////////////////////////
27 //////////////////////////////////////////////////////////////
29 // Utility class to evaluate the material budget from
30 // a given radius to the surface of an arbitrary cylinder
31 // along radial directions from the centre:
34 // - Interaction length
37 // Geantinos are shot in the bins in the fNtheta bins in theta
38 // and fNphi bins in phi with specified rectangular limits.
39 // The statistics are accumulated per
40 // fRadMin < r < fRadMax and <0 < z < fZMax
42 // To activate this option, you can do:
43 // Root > gAlice.RunLego();
44 // or Root > .x menu.C then select menu item "RunLego"
45 // Note that when calling gAlice->RunLego, an optional list
46 // of arguments may be specified.
50 <img src="picts/alilego.gif">
54 //////////////////////////////////////////////////////////////
64 //___________________________________________
73 //___________________________________________
74 AliLego::AliLego(const char *name, const char *title)
83 //___________________________________________
92 //___________________________________________
93 void AliLego::GenerateKinematics()
95 // Create a geantino with kinematics corresponding to the current
96 // bins in theta and phi.
100 const Int_t mpart = 0;
101 Float_t orig[3], pmom[3];
102 Float_t t, cost, sint, cosp, sinp;
104 // --- Set to 0 radiation length, absorption length and g/cm2 ---
109 fCurTheta = (fThetaMin+(fThetaBin-0.5)*(fThetaMax-fThetaMin)/fNtheta)*kDegrad;
110 fCurPhi = (fPhiMin+(fPhiBin-0.5)*(fPhiMax-fPhiMin)/fNphi)*kDegrad;
111 cost = TMath::Cos(fCurTheta);
112 sint = TMath::Sin(fCurTheta);
113 cosp = TMath::Cos(fCurPhi);
114 sinp = TMath::Sin(fCurPhi);
120 // --- Where to start
121 orig[0] = orig[1] = orig[2] = 0;
122 Float_t dalicz = 3000;
124 t = PropagateCylinder(orig,pmom,fRadMin,dalicz);
128 if (TMath::Abs(orig[2]) > fZMax) return;
131 // --- We do start here
132 Float_t polar[3]={0.,0.,0.};
134 gAlice->SetTrack(1, 0, mpart, pmom, orig, polar, 0, "LEGO ray", ntr);
137 //___________________________________________
138 void AliLego::Init(Int_t ntheta,Float_t themin,Float_t themax,
139 Int_t nphi,Float_t phimin,Float_t phimax,Float_t rmin,Float_t rmax,
142 // specify the angular limits and the size of the rectangular box
152 Float_t etamin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)fThetaMax*kDegrad/2,TMath::Pi()/2-1.e-10)));
153 Float_t etamax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)fThetaMin*kDegrad/2, 1.e-10)));
155 fHistRadl = new TH2F("hradl","Radiation length map", nphi,phimin,phimax,ntheta,themin,themax);
156 fHistAbso = new TH2F("habso","Interaction length map", nphi,phimin,phimax,ntheta,themin,themax);
157 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map", nphi,phimin,phimax,ntheta,themin,themax);
158 fHistReta = new TH2F("hetar","Radiation length vs. eta",nphi,phimin,phimax,ntheta,etamin,etamax);
162 //___________________________________________
163 Float_t AliLego::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z)
165 // Propagate to cylinder from inside
167 Double_t hnorm, sz, t, t1, t2, t3, sr;
169 const Float_t kSmall = 1e-8;
170 const Float_t kSmall2 = kSmall*kSmall;
172 // ---> Find intesection with Z planes
176 hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]));
180 if (d[2] > kSmall) sz = (z-x[2])/d[2];
181 else if (d[2] < -kSmall) sz = -(z+x[2])/d[2];
182 else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection
184 // ---> Intersection with cylinders
185 // Intersection point (x,y,z)
186 // (x,y,z) is on track : x=X(1)+t*D(1)
189 // (x,y,z) is on cylinder : x**2 + y**2 = R**2
191 // (D(1)**2+D(2)**2)*t**2
192 // +2.*(X(1)*D(1)+X(2)*D(2))*t
193 // +X(1)**2+X(2)**2-R**2=0
194 // ---> Solve second degree equation
195 t1 = d[0]*d[0] + d[1]*d[1];
197 t = sz; // ---> Track parallel to the z-axis, take distance to planes
199 t2 = x[0]*d[0] + x[1]*d[1];
200 t3 = x[0]*x[0] + x[1]*x[1];
201 // ---> It should be positive, but there may be numerical problems
202 sr = (t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1;
203 // ---> Find minimum distance between planes and cylinder
204 t = TMath::Min(sz,sr);
209 //___________________________________________
212 // loop on phi,theta bins
214 Float_t thed, phid, eta;
215 for (fPhiBin=1; fPhiBin<=fNphi; fPhiBin++) {
216 printf("AliLego Generating rays in phi bin:%d\n",fPhiBin);
217 for (fThetaBin=1; fThetaBin<=fNtheta; fThetaBin++) {
220 GenerateKinematics();
223 thed = fCurTheta*kRaddeg;
224 phid = fCurPhi*kRaddeg;
225 eta = -TMath::Log(TMath::Tan(TMath::Max(
226 TMath::Min((Double_t)fCurTheta/2,TMath::Pi()/2-1.e-10),1.e-10)));
227 fHistRadl->Fill(phid,thed,fTotRadl);
228 fHistAbso->Fill(phid,thed,fTotAbso);
229 fHistGcm2->Fill(phid,thed,fTotGcm2);
230 fHistReta->Fill(phid,eta,fTotRadl);
231 gAlice->FinishEvent();
234 // store histograms in current Root file
241 //___________________________________________
242 void AliLego::StepManager()
244 // called from AliRun::Stepmanager from gustep.
245 // Accumulate the 3 parameters step by step
248 Float_t a,z,dens,radl,absl;
251 Float_t step = gMC->TrackStep();
253 Float_t vect[3], dir[3];
254 TLorentzVector pos, mom;
256 gMC->TrackPosition(pos);
257 gMC->TrackMomentum(mom);
258 gMC->CurrentMaterial(a,z,dens,radl,absl);
262 // --- See if we have to stop now
263 if (TMath::Abs(pos[2]) > fZMax ||
264 pos[0]*pos[0] +pos[1]*pos[1] > fRadMax*fRadMax) {
265 if (gMC->TrackLength()) {
266 // Not the first step, add past contribution
275 // --- See how long we have to go
281 t = PropagateCylinder(vect,dir,fRadMax,fZMax);
283 fTotAbso += step/absl;
284 fTotRadl += step/radl;
285 fTotGcm2 += step*dens;