1 //////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////
4 // Utility class to evaluate the material budget from
5 // a given radius to the surface of an arbitrary cylinder
6 // along radial directions from the centre:
9 // - Interaction length
12 // Geantinos are shot in the bins in the fNtheta bins in theta
13 // and fNphi bins in phi with specified rectangular limits.
14 // The statistics are accumulated per
15 // fRadMin < r < fRadMax and <0 < z < fZMax
17 // To activate this option, you can do:
18 // Root > gAlice.RunLego();
19 // or Root > .x menu.C then select menu item "RunLego"
20 // Note that when calling gAlice->RunLego, an optional list
21 // of arguments may be specified.
25 <img src="picts/alilego.gif">
29 //////////////////////////////////////////////////////////////
39 //___________________________________________
48 //___________________________________________
49 AliLego::AliLego(const char *name, const char *title)
58 //___________________________________________
67 //___________________________________________
68 void AliLego::GenerateKinematics()
70 // Create a geantino with kinematics corresponding to the current
71 // bins in theta and phi.
75 const Int_t mpart = 0;
76 Float_t orig[3], pmom[3];
77 Float_t t, cost, sint, cosp, sinp;
79 // --- Set to 0 radiation length, absorption length and g/cm2 ---
84 fCurTheta = (fThetaMin+(fThetaBin-0.5)*(fThetaMax-fThetaMin)/fNtheta)*kDegrad;
85 fCurPhi = (fPhiMin+(fPhiBin-0.5)*(fPhiMax-fPhiMin)/fNphi)*kDegrad;
86 cost = TMath::Cos(fCurTheta);
87 sint = TMath::Sin(fCurTheta);
88 cosp = TMath::Cos(fCurPhi);
89 sinp = TMath::Sin(fCurPhi);
96 orig[0] = orig[1] = orig[2] = 0;
97 Float_t dalicz = 3000;
99 t = PropagateCylinder(orig,pmom,fRadMin,dalicz);
103 if (TMath::Abs(orig[2]) > fZMax) return;
106 // --- We do start here
107 Float_t polar[3]={0.,0.,0.};
109 gAlice->SetTrack(1, 0, mpart, pmom, orig, polar, 0, "LEGO ray", ntr);
112 //___________________________________________
113 void AliLego::Init(Int_t ntheta,Float_t themin,Float_t themax,
114 Int_t nphi,Float_t phimin,Float_t phimax,Float_t rmin,Float_t rmax,
117 // specify the angular limits and the size of the rectangular box
127 Float_t etamin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)fThetaMax*kDegrad/2,TMath::Pi()/2-1.e-10)));
128 Float_t etamax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)fThetaMin*kDegrad/2, 1.e-10)));
130 fHistRadl = new TH2F("hradl","Radiation length map", nphi,phimin,phimax,ntheta,themin,themax);
131 fHistAbso = new TH2F("habso","Interaction length map", nphi,phimin,phimax,ntheta,themin,themax);
132 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map", nphi,phimin,phimax,ntheta,themin,themax);
133 fHistReta = new TH2F("hetar","Radiation length vs. eta",nphi,phimin,phimax,ntheta,etamin,etamax);
137 //___________________________________________
138 Float_t AliLego::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z)
140 // Propagate to cylinder from inside
142 Double_t hnorm, sz, t, t1, t2, t3, sr;
144 const Float_t kSmall = 1e-8;
145 const Float_t kSmall2 = kSmall*kSmall;
147 // ---> Find intesection with Z planes
151 hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]));
155 if (d[2] > kSmall) sz = (z-x[2])/d[2];
156 else if (d[2] < -kSmall) sz = -(z+x[2])/d[2];
157 else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection
159 // ---> Intersection with cylinders
160 // Intersection point (x,y,z)
161 // (x,y,z) is on track : x=X(1)+t*D(1)
164 // (x,y,z) is on cylinder : x**2 + y**2 = R**2
166 // (D(1)**2+D(2)**2)*t**2
167 // +2.*(X(1)*D(1)+X(2)*D(2))*t
168 // +X(1)**2+X(2)**2-R**2=0
169 // ---> Solve second degree equation
170 t1 = d[0]*d[0] + d[1]*d[1];
172 t = sz; // ---> Track parallel to the z-axis, take distance to planes
174 t2 = x[0]*d[0] + x[1]*d[1];
175 t3 = x[0]*x[0] + x[1]*x[1];
176 // ---> It should be positive, but there may be numerical problems
177 sr = (t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1;
178 // ---> Find minimum distance between planes and cylinder
179 t = TMath::Min(sz,sr);
184 //___________________________________________
187 // loop on phi,theta bins
189 Float_t thed, phid, eta;
190 for (fPhiBin=1; fPhiBin<=fNphi; fPhiBin++) {
191 printf("AliLego Generating rays in phi bin:%d\n",fPhiBin);
192 for (fThetaBin=1; fThetaBin<=fNtheta; fThetaBin++) {
195 GenerateKinematics();
198 thed = fCurTheta*kRaddeg;
199 phid = fCurPhi*kRaddeg;
200 eta = -TMath::Log(TMath::Tan(TMath::Max(
201 TMath::Min((Double_t)fCurTheta/2,TMath::Pi()/2-1.e-10),1.e-10)));
202 fHistRadl->Fill(phid,thed,fTotRadl);
203 fHistAbso->Fill(phid,thed,fTotAbso);
204 fHistGcm2->Fill(phid,thed,fTotGcm2);
205 fHistReta->Fill(phid,eta,fTotRadl);
206 gAlice->FinishEvent();
209 // store histograms in current Root file
216 //___________________________________________
217 void AliLego::StepManager()
219 // called from AliRun::Stepmanager from gustep.
220 // Accumulate the 3 parameters step by step
223 Float_t a,z,dens,radl,absl;
226 Float_t step = gMC->TrackStep();
228 Float_t vect[3], dir[3];
229 TLorentzVector pos, mom;
231 gMC->TrackPosition(pos);
232 gMC->TrackMomentum(mom);
233 gMC->CurrentMaterial(a,z,dens,radl,absl);
237 // --- See if we have to stop now
238 if (TMath::Abs(pos[2]) > fZMax ||
239 pos[0]*pos[0] +pos[1]*pos[1] > fRadMax*fRadMax) {
243 // --- See how long we have to go
248 t = PropagateCylinder(vect,dir,fRadMax,fZMax);
249 tt = TMath::Min(step,t);