/*
$Log$
+Revision 1.20 2000/11/30 07:12:48 alibrary
+Introducing new Rndm and QA classes
+
+Revision 1.19 2000/10/26 14:13:05 morsch
+- Change from coordinates theta, phi to general coordinates Coor1 and Coor2.
+- Lego generator instance can be passed in constructor.
+
+Revision 1.18 2000/10/02 21:28:14 fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.17 2000/07/12 08:56:25 fca
+Coding convention correction and warning removal
+
+Revision 1.16 2000/05/26 08:35:03 fca
+Move the check on z after z has been retrieved
+
+Revision 1.15 2000/05/16 13:10:40 fca
+New method IsNewTrack and fix for a problem in Father-Daughter relations
+
+Revision 1.14 2000/04/27 10:38:21 fca
+Correct termination of Lego Run and introduce Lego getter in AliRun
+
+Revision 1.13 2000/04/26 10:17:31 fca
+Changes in Lego for G4 compatibility
+
+Revision 1.12 2000/04/07 11:12:33 fca
+G4 compatibility changes
+
Revision 1.11 2000/03/22 13:42:26 fca
SetGenerator does not replace an existing generator, ResetGenerator does
//////////////////////////////////////////////////////////////
#include "TMath.h"
+
#include "AliLego.h"
-#include "AliRun.h"
+#include "AliLegoGenerator.h"
#include "AliConst.h"
#include "AliMC.h"
+#include "TH2.h"
ClassImp(AliLego)
//___________________________________________
AliLego::AliLego()
{
- fHistRadl = 0;
- fHistAbso = 0;
- fHistGcm2 = 0;
- fHistReta = 0;
+ //
+ // Default constructor
+ //
+ fHistRadl = 0;
+ fHistAbso = 0;
+ fHistGcm2 = 0;
+ fHistReta = 0;
}
//___________________________________________
-AliLego::AliLego(const char *title, Int_t ntheta, Float_t themin, Float_t themax,
- Int_t nphi, Float_t phimin, Float_t phimax,
+AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin,
+ Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax,
Float_t rmin, Float_t rmax, Float_t zmax)
: TNamed("Lego Generator",title)
{
-// specify the angular limits and the size of the rectangular box
-
- fGener = new AliLegoGenerator(ntheta, themin, themax,
+ //
+ // specify the angular limits and the size of the rectangular box
+ //
+ fGener = new AliLegoGenerator(ntheta, thetamin, thetamax,
nphi, phimin, phimax, rmin, rmax, zmax);
- gAlice->ResetGenerator(fGener);
-
- Float_t etamin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)themax*kDegrad/2,TMath::Pi()/2-1.e-10)));
- Float_t etamax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)themin*kDegrad/2, 1.e-10)));
+
fHistRadl = new TH2F("hradl","Radiation length map",
- nphi,phimin,phimax,ntheta,themin,themax);
+ ntheta,thetamin,thetamax,nphi,phimin,phimax);
fHistAbso = new TH2F("habso","Interaction length map",
- nphi,phimin,phimax,ntheta,themin,themax);
+ ntheta,thetamin,thetamax,nphi,phimin,phimax);
fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
- nphi,phimin,phimax,ntheta,themin,themax);
- fHistReta = new TH2F("hetar","Radiation length vs. eta",
- nphi,phimin,phimax,ntheta,etamin,etamax);
+ ntheta,thetamin,thetamax,nphi,phimin,phimax);
+}
+AliLego::AliLego(const char *title, AliLegoGenerator* generator)
+ : TNamed("Lego Generator",title)
+{
+ //
+ // specify the angular limits and the size of the rectangular box
+ //
+ fGener = generator;
+ Float_t c1min, c1max, c2min, c2max;
+ Int_t n1 = fGener->NCoor1();
+ Int_t n2 = fGener->NCoor2();
+
+ fGener->Coor1Range(c1min, c1max);
+ fGener->Coor2Range(c2min, c2max);
+
+ fHistRadl = new TH2F("hradl","Radiation length map",
+ n2, c2min, c2max, n1, c1min, c1max);
+ fHistAbso = new TH2F("habso","Interaction length map",
+ n2, c2min, c2max, n1, c1min, c1max);
+ fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
+ n2, c2min, c2max, n1, c1min, c1max);
}
//___________________________________________
AliLego::~AliLego()
{
- delete fHistRadl;
- delete fHistAbso;
- delete fHistGcm2;
- delete fHistReta;
+ //
+ // Destructor
+ //
+ delete fHistRadl;
+ delete fHistAbso;
+ delete fHistGcm2;
+ delete fGener;
}
+//___________________________________________
+void AliLego::BeginEvent()
+{
+ //
+ // --- Set to 0 radiation length, absorption length and g/cm2 ---
+ //
+ fTotRadl = 0;
+ fTotAbso = 0;
+ fTotGcm2 = 0;
+}
//___________________________________________
-void AliLego::Run()
+void AliLego::FinishEvent()
{
- // loop on phi,theta bins
- gMC->InitLego();
- Float_t thed, phid, eta;
- for (Int_t i=0; i<=fGener->Nphi()*fGener->Ntheta(); ++i) {
-// --- Set to 0 radiation length, absorption length and g/cm2 ---
- fTotRadl = 0;
- fTotAbso = 0;
- fTotGcm2 = 0;
-
- gMC->ProcessEvent();
-
- thed = fGener->CurTheta()*kRaddeg;
- phid = fGener->CurPhi()*kRaddeg;
- eta = -TMath::Log(TMath::Tan(TMath::Max(
- TMath::Min((Double_t)(fGener->CurTheta())/2,
- TMath::Pi()/2-1.e-10),1.e-10)));
-
- fHistRadl->Fill(phid,thed,fTotRadl);
- fHistAbso->Fill(phid,thed,fTotAbso);
- fHistGcm2->Fill(phid,thed,fTotGcm2);
- fHistReta->Fill(phid,eta,fTotRadl);
- gAlice->FinishEvent();
- }
- // store histograms in current Root file
- fHistRadl->Write();
- fHistAbso->Write();
- fHistGcm2->Write();
- fHistReta->Write();
+ //
+ // Finish the event and update the histos
+ //
+ Double_t c1, c2;
+ c1 = fGener->CurCoor1();
+ c2 = fGener->CurCoor2();
+ fHistRadl->Fill(c2,c1,fTotRadl);
+ fHistAbso->Fill(c2,c1,fTotAbso);
+ fHistGcm2->Fill(c2,c1,fTotGcm2);
+}
+
+//___________________________________________
+void AliLego::FinishRun()
+{
+ //
+ // Store histograms in current Root file
+ //
+ fHistRadl->Write();
+ fHistAbso->Write();
+ fHistGcm2->Write();
+
+ // Delete histograms from memory
+ fHistRadl->Delete(); fHistRadl=0;
+ fHistAbso->Delete(); fHistAbso=0;
+ fHistGcm2->Delete(); fHistGcm2=0;
+}
+
+//___________________________________________
+void AliLego::Copy(AliLego &lego) const
+{
+ //
+ // Copy *this onto lego -- not implemented
+ //
+ Fatal("Copy","Not implemented!\n");
}
//___________________________________________
Float_t vect[3], dir[3];
TLorentzVector pos, mom;
- gMC->TrackPosition(pos);
- gMC->TrackMomentum(mom);
gMC->CurrentMaterial(a,z,dens,radl,absl);
if (z < 1) return;
-
+
+ gMC->TrackPosition(pos);
+ gMC->TrackMomentum(mom);
// --- See if we have to stop now
if (TMath::Abs(pos[2]) > fGener->ZMax() ||
pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
- if (gMC->TrackLength()) {
+ if (!gMC->IsNewTrack()) {
// Not the first step, add past contribution
fTotAbso += t/absl;
fTotRadl += t/radl;
fTotGcm2 += t*dens;
+// Int_t copy;
+// Int_t id = gMC->CurrentVolID(copy);
+// char* vol = gMC->VolName(id);
+
+// printf("\n %f %f %f %f %s ", fTotRadl, vect[0], vect[1], vect[2], vol);
+
}
gMC->StopTrack();
return;
fTotAbso += step/absl;
fTotRadl += step/radl;
fTotGcm2 += step*dens;
+// Int_t copy;
+// Int_t id = gMC->CurrentVolID(copy);
+// char* vol = gMC->VolName(id);
+// printf("\n %f %f %f %f %s %f ", fTotRadl, vect[0], vect[1], vect[2], vol, t);
}
}
-ClassImp(AliLegoGenerator)
-
-//___________________________________________
-AliLegoGenerator::AliLegoGenerator(Int_t ntheta, Float_t themin,
- Float_t themax, Int_t nphi,
- Float_t phimin, Float_t phimax,
- Float_t rmin, Float_t rmax, Float_t zmax) :
- AliGenerator(0), fRadMin(rmin), fRadMax(rmax), fZMax(zmax), fNtheta(ntheta),
- fNphi(nphi), fThetaBin(ntheta), fPhiBin(-1), fCurTheta(0), fCurPhi(0)
-
-{
- SetPhiRange(phimin,phimax);
- SetThetaRange(themin,themax);
- SetName("Lego");
-}
-
-//___________________________________________
-void AliLegoGenerator::Generate()
-{
-// Create a geantino with kinematics corresponding to the current
-// bins in theta and phi.
-
- //
- // Rootinos are 0
- const Int_t mpart = 0;
- Float_t orig[3], pmom[3];
- Float_t t, cost, sint, cosp, sinp;
-
- // Prepare for next step
- if(fThetaBin>=fNtheta-1)
- if(fPhiBin>=fNphi-1) {
- Warning("Generate","End of Lego Generation");
- return;
- } else {
- fPhiBin++;
- printf("Generating rays in phi bin:%d\n",fPhiBin);
- fThetaBin=0;
- } else fThetaBin++;
-
- fCurTheta = (fThetaMin+(fThetaBin+0.5)*(fThetaMax-fThetaMin)/fNtheta);
- fCurPhi = (fPhiMin+(fPhiBin+0.5)*(fPhiMax-fPhiMin)/fNphi);
- cost = TMath::Cos(fCurTheta);
- sint = TMath::Sin(fCurTheta);
- cosp = TMath::Cos(fCurPhi);
- sinp = TMath::Sin(fCurPhi);
-
- pmom[0] = cosp*sint;
- pmom[1] = sinp*sint;
- pmom[2] = cost;
-
- // --- Where to start
- orig[0] = orig[1] = orig[2] = 0;
- Float_t dalicz = 3000;
- if (fRadMin > 0) {
- t = PropagateCylinder(orig,pmom,fRadMin,dalicz);
- orig[0] = pmom[0]*t;
- orig[1] = pmom[1]*t;
- orig[2] = pmom[2]*t;
- if (TMath::Abs(orig[2]) > fZMax) return;
- }
-
- Float_t polar[3]={0.,0.,0.};
- Int_t ntr;
- gAlice->SetTrack(1, 0, mpart, pmom, orig, polar, 0, "LEGO ray", ntr);
-}
-//___________________________________________
-Float_t AliLegoGenerator::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z)
-{
-// Propagate to cylinder from inside
-
- Double_t hnorm, sz, t, t1, t2, t3, sr;
- Double_t d[3];
- const Float_t kSmall = 1e-8;
- const Float_t kSmall2 = kSmall*kSmall;
-
-// ---> Find intesection with Z planes
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- hnorm = TMath::Sqrt(1/(d[0]*d[0]+d[1]*d[1]+d[2]*d[2]));
- d[0] *= hnorm;
- d[1] *= hnorm;
- d[2] *= hnorm;
- if (d[2] > kSmall) sz = (z-x[2])/d[2];
- else if (d[2] < -kSmall) sz = -(z+x[2])/d[2];
- else sz = 1.e10; // ---> Direction parallel to X-Y, no intersection
-
-// ---> Intersection with cylinders
-// Intersection point (x,y,z)
-// (x,y,z) is on track : x=X(1)+t*D(1)
-// y=X(2)+t*D(2)
-// z=X(3)+t*D(3)
-// (x,y,z) is on cylinder : x**2 + y**2 = R**2
-//
-// (D(1)**2+D(2)**2)*t**2
-// +2.*(X(1)*D(1)+X(2)*D(2))*t
-// +X(1)**2+X(2)**2-R**2=0
-// ---> Solve second degree equation
- t1 = d[0]*d[0] + d[1]*d[1];
- if (t1 <= kSmall2) {
- t = sz; // ---> Track parallel to the z-axis, take distance to planes
- } else {
- t2 = x[0]*d[0] + x[1]*d[1];
- t3 = x[0]*x[0] + x[1]*x[1];
- // ---> It should be positive, but there may be numerical problems
- sr = (t2 +TMath::Sqrt(TMath::Max(t2*t2-(t3-r*r)*t1,0.)))/t1;
- // ---> Find minimum distance between planes and cylinder
- t = TMath::Min(sz,sr);
- }
- return t;
-}