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.
73 const Int_t mpart = 48;
74 Float_t orig[3], pmom[3];
75 Float_t t, cost, sint, cosp, sinp;
77 // --- Set to 0 radiation length, absorption length and g/cm2 ---
82 fCurTheta = (fThetaMin+(fThetaBin-0.5)*(fThetaMax-fThetaMin)/fNtheta)*kDegrad;
83 fCurPhi = (fPhiMin+(fPhiBin-0.5)*(fPhiMax-fPhiMin)/fNphi)*kDegrad;
84 cost = TMath::Cos(fCurTheta);
85 sint = TMath::Sin(fCurTheta);
86 cosp = TMath::Cos(fCurPhi);
87 sinp = TMath::Sin(fCurPhi);
94 orig[0] = orig[1] = orig[2] = 0;
95 Float_t dalicz = 3000;
97 t = PropagateCylinder(orig,pmom,fRadMin,dalicz);
101 if (TMath::Abs(orig[2]) > fZMax) return;
104 // --- We do start here
105 Float_t polar[3]={0.,0.,0.};
107 gAlice->SetTrack(1, 0, mpart, pmom, orig, polar, 0, "LEGO ray", ntr);
110 //___________________________________________
111 void AliLego::Init(Int_t ntheta,Float_t themin,Float_t themax,
112 Int_t nphi,Float_t phimin,Float_t phimax,Float_t rmin,Float_t rmax,
115 // specify the angular limits and the size of the rectangular box
125 Float_t etamin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)fThetaMax*kDegrad/2,TMath::Pi()/2-1.e-10)));
126 Float_t etamax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)fThetaMin*kDegrad/2, 1.e-10)));
128 fHistRadl = new TH2F("hradl","Radiation length map", nphi,phimin,phimax,ntheta,themin,themax);
129 fHistAbso = new TH2F("habso","Interaction length map", nphi,phimin,phimax,ntheta,themin,themax);
130 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map", nphi,phimin,phimax,ntheta,themin,themax);
131 fHistReta = new TH2F("hetar","Radiation length vs. eta",nphi,phimin,phimax,ntheta,etamin,etamax);
135 //___________________________________________
136 Float_t AliLego::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z)
138 // Propagate to cylinder from inside
140 Double_t hnorm, sz, t, t1, t2, t3, sr;
142 const Float_t kSmall = 1e-8;
143 const Float_t kSmall2 = kSmall*kSmall;
145 // ---> Find intesection with Z planes
149 hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]));
153 if (d[2] > kSmall) sz = (z-x[2])/d[2];
154 else if (d[2] < -kSmall) sz = -(z+x[2])/d[2];
155 else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection
157 // ---> Intersection with cylinders
158 // Intersection point (x,y,z)
159 // (x,y,z) is on track : x=X(1)+t*D(1)
162 // (x,y,z) is on cylinder : x**2 + y**2 = R**2
164 // (D(1)**2+D(2)**2)*t**2
165 // +2.*(X(1)*D(1)+X(2)*D(2))*t
166 // +X(1)**2+X(2)**2-R**2=0
167 // ---> Solve second degree equation
168 t1 = d[0]*d[0] + d[1]*d[1];
170 t = sz; // ---> Track parallel to the z-axis, take distance to planes
172 t2 = x[0]*d[0] + x[1]*d[1];
173 t3 = x[0]*x[0] + x[1]*x[1];
174 // ---> It should be positive, but there may be numerical problems
175 sr = (t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1;
176 // ---> Find minimum distance between planes and cylinder
177 t = TMath::Min(sz,sr);
182 //___________________________________________
185 // loop on phi,theta bins
186 AliMC* pMC=AliMC::GetMC();
188 Float_t thed, phid, eta;
189 for (fPhiBin=1; fPhiBin<=fNphi; fPhiBin++) {
190 printf("AliLego Generating rays in phi bin:%d\n",fPhiBin);
191 for (fThetaBin=1; fThetaBin<=fNtheta; fThetaBin++) {
194 GenerateKinematics();
197 thed = fCurTheta*kRaddeg;
198 phid = fCurPhi*kRaddeg;
199 eta = -TMath::Log(TMath::Tan(TMath::Max(
200 TMath::Min((Double_t)fCurTheta/2,TMath::Pi()/2-1.e-10),1.e-10)));
201 fHistRadl->Fill(phid,thed,fTotRadl);
202 fHistAbso->Fill(phid,thed,fTotAbso);
203 fHistGcm2->Fill(phid,thed,fTotGcm2);
204 fHistReta->Fill(phid,eta,fTotRadl);
205 gAlice->FinishEvent();
208 // store histograms in current Root file
215 //___________________________________________
216 void AliLego::StepManager()
218 // called from AliRun::Stepmanager from gustep.
219 // Accumulate the 3 parameters step by step
220 AliMC* pMC = AliMC::GetMC();
223 Float_t a,z,dens,radl,absl;
225 Float_t step = pMC->TrackStep();
227 Float_t vect[3], pmom[4];
228 pMC->TrackPosition(vect);
229 pMC->TrackMomentum(pmom);
230 pMC->CurrentMaterial(a,z,dens,radl,absl);
234 // --- See if we have to stop now
235 if (TMath::Abs(vect[2]) > fZMax ||
236 vect[0]*vect[0] +vect[1]*vect[1] > fRadMax*fRadMax) {
240 // --- See how long we have to go
241 t = PropagateCylinder(vect,pmom,fRadMax,fZMax);
242 tt = TMath::Min(step,t);