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