]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliLegoGeneratorXYZ.cxx
d3ae6bd7a3ac46ce7a10a2f689ede3cd6657fb00
[u/mrichter/AliRoot.git] / STEER / AliLegoGeneratorXYZ.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Header$ */
17
18 //-------------------------------------------------------------------------
19 //
20 //      Lego generator in x - y - z bins
21 //
22 //-------------------------------------------------------------------------
23
24 #include "AliLegoGeneratorXYZ.h"
25 #include "AliRun.h"
26
27 ClassImp(AliLegoGeneratorXYZ)
28
29
30 //___________________________________________
31     
32
33 AliLegoGeneratorXYZ::AliLegoGeneratorXYZ()
34 {
35 // Default Constructor
36     fDir1[0]=1.; fDir1[1]=0.; fDir1[2]=0.;
37     fDir2[0]=0.; fDir2[1]=1.; fDir2[2]=0.;    
38     fDir3[0]=0.; fDir3[1]=0.; fDir3[2]=1.;    
39 }
40
41 AliLegoGeneratorXYZ::AliLegoGeneratorXYZ(char* axis)
42 {
43 // Constructor
44     if (!strcmp(axis,"x") || !strcmp(axis,"X")) 
45     {
46         fDir1[0]=0.; fDir1[1]=1.; fDir1[2]=0.;
47         fDir2[0]=0.; fDir2[1]=0.; fDir2[2]=1.;    
48         fDir3[0]=1.; fDir3[1]=0.; fDir3[2]=0.;    
49     }
50     else if (!strcmp(axis,"y") || !strcmp(axis,"Y")) 
51     {
52         fDir1[0]=1.; fDir1[1]=0.; fDir1[2]=0.;
53         fDir2[0]=0.; fDir2[1]=0.; fDir2[2]=1;    
54         fDir3[0]=0.; fDir3[1]=1.; fDir3[2]=0.;    
55     }
56     else if (!strcmp(axis,"z") || !strcmp(axis,"Z")) 
57     {
58         fDir1[0]=1.; fDir1[1]=0.; fDir1[2]=0.;
59         fDir2[0]=0.; fDir2[1]=1.; fDir2[2]=0.;    
60         fDir3[0]=0.; fDir3[1]=0.; fDir3[2]=1.;    
61     }
62     else 
63     {
64         fDir1[0]=1.; fDir1[1]=0.; fDir1[2]=0.;
65         fDir2[0]=0.; fDir2[1]=1.; fDir2[2]=0.;    
66         fDir3[0]=0.; fDir3[1]=0.; fDir3[2]=1.;    
67     }
68 }
69
70
71 AliLegoGeneratorXYZ::AliLegoGeneratorXYZ(Int_t nc1, Float_t c1min,
72                                          Float_t c1max, Int_t nc2, 
73                                          Float_t c2min, Float_t c2max,
74                                          Float_t rmin, Float_t rmax, Float_t zmax) : 
75     AliLegoGenerator(nc1, c1min, c1max, nc2, c2min, c2max,
76                      rmin, rmax, zmax)
77 {
78 //  Constructor
79     fDir1[0]=1.; fDir1[1]=0.; fDir1[2]=0.;
80     fDir2[0]=0.; fDir2[1]=1.; fDir2[2]=0.;    
81     fDir3[0]=0.; fDir3[1]=0.; fDir3[2]=1.;    
82 }
83
84
85 //___________________________________________
86 void AliLegoGeneratorXYZ::Generate()
87 {
88 // Create a geantino with kinematics corresponding to the current bins
89 // Here: Coor1 =  x 
90 //       Coor2 =  z
91    
92   //
93   // Rootinos are 0
94    const Int_t kMpart = 0;
95    Float_t orig[3], pmom[3];
96    
97    // Prepare for next step
98    if(fCoor1Bin>=fNCoor1-1)
99      if(fCoor2Bin>=fNCoor2-1) {
100        Warning("Generate","End of Lego Generation");
101        return;
102      } else { 
103        fCoor2Bin++;
104        printf("Generating rays in Coordinate 2 bin:%d\n",fCoor2Bin);
105        fCoor1Bin=0;
106      } else fCoor1Bin++;
107
108    
109    fCurCoor1 = (fCoor1Min+(fCoor1Bin+0.5)*(fCoor1Max-fCoor1Min)/fNCoor1);
110    fCurCoor2 = (fCoor2Min+(fCoor2Bin+0.5)*(fCoor2Max-fCoor2Min)/fNCoor2);
111
112 // Origin and direction
113    Int_t i;
114    for (i=0; i<3; i++) {
115        pmom[i]=fDir3[i];
116        orig[i]=fCurCoor1*fDir1[i]+fCurCoor2*fDir2[i];
117    }
118    
119    Float_t dalicz = 3000;
120    if (fRadMin > 0) {
121        Float_t t = PropagateCylinder(orig,pmom,fRadMin,dalicz);
122        orig[0] = pmom[0]*t;
123        orig[1] = pmom[1]*t;
124        orig[2] = pmom[2]*t;
125        if (TMath::Abs(orig[2]) > fZMax) return;
126    }
127    
128    Float_t polar[3]={0.,0.,0.};
129    Int_t ntr;
130    gAlice->SetTrack(1, -1, kMpart, pmom, orig, polar, 0, kPPrimary, ntr);
131    
132 }
133
134
135
136