]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- Base class now
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Oct 2000 14:15:54 +0000 (14:15 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Oct 2000 14:15:54 +0000 (14:15 +0000)
- Change from theta, phi to general coordinates Coor1, Coor2
- PropagateCylinder: bug in calculation of distance to limiting radius corrected.

STEER/AliLegoGenerator.cxx
STEER/AliLegoGenerator.h

index 101fce42e7e83be372ec87d38c37a2503b3bb027..a95fab6c3f613c474b75daf034ca2011b20804f3 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.2  2000/07/13 16:19:09  fca
+Mainly coding conventions + some small bug fixes
+
 Revision 1.1  2000/07/12 08:56:25  fca
 Coding convention correction and warning removal
 
@@ -48,7 +51,6 @@ Correct logics for Lego StepManager
 
 Revision 1.7  1999/09/29 09:24:29  fca
 Introduction of the Copyright and cvs Log
-
 */
 
 #include "AliLegoGenerator.h"
@@ -57,52 +59,64 @@ Introduction of the Copyright and cvs Log
 ClassImp(AliLegoGenerator)
 
 //___________________________________________
-AliLegoGenerator::AliLegoGenerator(Int_t ntheta, Float_t themin,
-                                  Float_t themax, Int_t nphi, 
-                                  Float_t phimin, Float_t phimax,
+
+AliLegoGenerator::AliLegoGenerator()
+{
+  //
+  // Default Constructor
+  //
+  SetName("Lego");
+
+  fCoor1Bin  =  fCoor2Bin = -1;
+  fCurCoor1  =  fCurCoor2 =  0;
+}
+
+AliLegoGenerator::AliLegoGenerator(Int_t nc1, Float_t c1min,
+                                  Float_t c1max, Int_t nc2, 
+                                  Float_t c2min, Float_t c2max,
                                   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)
+  AliGenerator(0), fRadMin(rmin), fRadMax(rmax), fZMax(zmax), fNCoor1(nc1),
+  fNCoor2(nc2), fCoor1Bin(nc1), fCoor2Bin(-1), fCurCoor1(0), fCurCoor2(0)
   
 {
   //
   // Standard generator for Lego rays
   //
-  SetPhiRange(phimin,phimax);
-  SetThetaRange(themin,themax);
+  SetCoor1Range(nc1, c1min, c1max);
+  SetCoor2Range(nc2, c2min, c2max);
   SetName("Lego");
 }
 
-
 //___________________________________________
 void AliLegoGenerator::Generate()
 {
-// Create a geantino with kinematics corresponding to the current
-// bins in theta and phi.
+// Create a geantino with kinematics corresponding to the current bins
+// Here: Coor1 =  theta 
+//       Coor2 =  phi.
    
   //
   // Rootinos are 0
    const Int_t kMpart = 0;
    Float_t orig[3], pmom[3];
    Float_t t, cost, sint, cosp, sinp;
-   
+   if (fCoor1Bin==-1) fCoor1Bin=fNCoor1;
    // Prepare for next step
-   if(fThetaBin>=fNtheta-1)
-     if(fPhiBin>=fNphi-1) {
+   if(fCoor1Bin>=fNCoor1-1)
+     if(fCoor2Bin>=fNCoor2-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);
+       fCoor2Bin++;
+       printf("Generating rays in phi bin:%d\n",fCoor2Bin);
+       fCoor1Bin=0;
+     } else fCoor1Bin++;
+
+   fCurCoor1 = (fCoor1Min+(fCoor1Bin+0.5)*(fCoor1Max-fCoor1Min)/fNCoor1);
+   fCurCoor2 = (fCoor2Min+(fCoor2Bin+0.5)*(fCoor2Max-fCoor2Min)/fNCoor2);
+   cost      = TMath::Cos(fCurCoor1 * TMath::Pi()/180.);
+   sint      = TMath::Sin(fCurCoor1 * TMath::Pi()/180.);
+   cosp      = TMath::Cos(fCurCoor2 * TMath::Pi()/180.);
+   sinp      = TMath::Sin(fCurCoor2 * TMath::Pi()/180.);
    
    pmom[0] = cosp*sint;
    pmom[1] = sinp*sint;
@@ -112,17 +126,17 @@ void AliLegoGenerator::Generate()
    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;
+       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, kMpart, pmom, orig, polar, 0, "LEGO ray", ntr);
-
+   
 }
 
 //___________________________________________
@@ -165,10 +179,11 @@ Float_t AliLegoGenerator::PropagateCylinder(Float_t *x, Float_t *v, Float_t r, F
       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;
+      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;
 }
 
+
index 76fa714789b5d0cd95b4e18d8318eb2cf3616b2d..507f830580afaacb48ad44a581f3a1d5fd47a8e9 100644 (file)
 
 #include "AliGenerator.h"
 
-class AliLegoGenerator : public AliGenerator
+class AliLegoGenerator:
+public AliGenerator
 {
 
-public:
-  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);
-  void    Generate();
-  Float_t CurTheta() const {return fCurTheta;}
-  Int_t   ThetaBin() const {return fThetaBin;}
-  Float_t CurPhi() const {return fCurPhi;}
-  Float_t ZMax() const {return fZMax;}
-  Float_t RadMax() const {return fRadMax;}
-  Int_t   PhiBin() const {return fPhiBin;}
-  Int_t   Nphi() const {return fNphi;}
-  Int_t   Ntheta() const {return fNtheta;}
-  Float_t       PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z);
-private:
-   Float_t    fRadMin;          //Generation radius
-   Float_t    fRadMax;          //Maximum tracking radius
-   Float_t    fZMax;            //Maximum tracking Z
-   Int_t      fNtheta;          //Number of bins in Theta
-   Int_t      fNphi;            //Number of bins in Phi
-   Int_t      fThetaBin;        //Current theta bin
-   Int_t      fPhiBin;          //Current phi bin
-   Float_t    fCurTheta;        //Current theta of track
-   Float_t    fCurPhi;          //Current phi of track
-
-  ClassDef(AliLegoGenerator,1) //Lego generator
+public: 
+    AliLegoGenerator();
+    
+    AliLegoGenerator(Int_t nc1, Float_t c1min, Float_t c1max,
+                    Int_t nc2, Float_t c2min, Float_t c2max,
+                    Float_t rmin, Float_t rmax, Float_t zmax);
+    virtual void    Generate();
+    virtual void    SetCoor1Range(Int_t nbin, Float_t c1min, Float_t c1max)
+       {fNCoor1=nbin; fCoor1Min=c1min; fCoor1Max=c1max;}
+    virtual Float_t CurCoor1() const {return fCurCoor1;}
+    virtual Int_t   Coor1Bin() const {return fCoor1Bin;}
+    virtual void    SetCoor2Range(Int_t nbin, Float_t c2min, Float_t c2max)
+       {fNCoor2=nbin; fCoor2Min=c2min; fCoor2Max=c2max;}    
+    virtual Float_t CurCoor2() const {return fCurCoor2;}
+    virtual Int_t   Coor2Bin() const {return fCoor2Bin;}
+
+    virtual void    SetRadiusRange(Float_t rmin, Float_t rmax) 
+       {fRadMin=rmin; fRadMax=rmax;}
+    virtual void    SetZMax(Float_t zmax) 
+       {fZMax=zmax;}
+           
+    virtual Float_t ZMax()   const {return fZMax;}
+    virtual Float_t RadMax() const {return fRadMax;}
+    virtual Int_t   NCoor1() const {return fNCoor1;}
+    virtual Int_t   NCoor2() const {return fNCoor2;}
+    virtual void    Coor1Range(Float_t &c1min, Float_t &c1max) const
+       {c1min =  fCoor1Min; c1max =  fCoor1Max;}
+    virtual void    Coor2Range(Float_t &c2min, Float_t &c2max) const
+       {c2min =  fCoor2Min; c2max =  fCoor2Max;}
+           
+    Float_t         PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z);
+ protected:
+    Float_t    fRadMin;             // Generation radius
+    Float_t    fRadMax;             // Maximum tracking radius
+    Float_t    fZMax;               // Maximum tracking Z
+    Int_t      fNCoor1;             // Number of bins in Coor1
+    Int_t      fNCoor2;             // Number of bins in Coor2
+
+    Float_t    fCoor1Min;           // Minimum Coor1
+    Float_t    fCoor1Max;           // Maximum Coor1
+    Float_t    fCoor2Min;           // Minimum Coor2
+    Float_t    fCoor2Max;           // Maximum Coor2 
+    
+    Int_t      fCoor1Bin;           //Current Coor1 bin
+    Int_t      fCoor2Bin;           //Current Coor2 bin
+    Float_t    fCurCoor1;           //Current Coor1 of track
+    Float_t    fCurCoor2;           //Current c2 of track
+    
+    ClassDef(AliLegoGenerator,1) //Lego generator
 };
 
 #endif