]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTUBE.cxx
SetChildMomentumRange, SetChildPtRange, SetChildPhiRange, SetChildThetaRange added.
[u/mrichter/AliRoot.git] / MUON / AliMUONTUBE.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 /*
17 $Log$
18 */
19
20 #include <AliMUONTUBE.h>
21 #include <TTUBE.h>
22 #include "TVirtualPad.h"
23 ClassImp(AliMUONTUBE)
24
25 AliMUONTUBE::AliMUONTUBE():TTUBE()
26 {;}
27
28 //_____________________________________________________________________________
29
30 AliMUONTUBE::AliMUONTUBE(Text_t *name, Text_t *title, Text_t *material, Float_t rmin, 
31                          Float_t rmax, Float_t dz,Float_t aspect):
32     TTUBE(name, title, material, rmin, rmax, dz, aspect)
33 {}
34
35 //______________________________________________________________________________
36  AliMUONTUBE::AliMUONTUBE(Text_t *name, Text_t *title, Text_t *material, Float_t rmax, 
37                           Float_t dz)
38       : TTUBE(name, title, material, rmax, dz)
39 {
40 }
41
42 //______________________________________________________________________________
43  void AliMUONTUBE::Paint(Option_t *option)
44 {
45 //*-*-*-*-*-*-*-*Paint this 3-D shape with its current attributes*-*-*-*-*-*-*-*
46 //*-*            ================================================
47
48    Int_t i, j;
49    Int_t n = GetNumberOfDivisions();
50    const Int_t numpoints = 4*n;
51
52 //*-* Allocate memory for points *-*
53
54    Float_t *points = new Float_t[3*numpoints];
55    if (!points) return;
56
57    SetPoints(points);
58
59    if (gPad->GetView3D()) PaintGLPoints(points);
60
61 //==   for (i = 0; i < numpoints; i++)
62 //==            gNode->Local2Master(&points[3*i],&points[3*i]);
63
64     X3DBuffer *buff = new X3DBuffer;
65     if (buff) {
66         buff->numPoints = numpoints;
67         buff->numSegs   = n*6;
68         if (strstr(option, "x3d"))  buff->numSegs   = n*8;
69         buff->numPolys  = n*4;
70     }
71
72 //*-* Allocate memory for points *-*
73
74     buff->points = points;
75
76     Int_t c = ((GetLineColor() % 8) - 1) * 4;     // Basic colors: 0, 1, ... 7
77     if (c < 0) c = 0;
78
79 //*-* Allocate memory for segments *-*
80
81     buff->segs = new Int_t[buff->numSegs*3];
82     if (buff->segs) {
83         for (i = 0; i < 4; i++) {
84             for (j = 0; j < n; j++) {
85                 buff->segs[(i*n+j)*3  ] = c;
86                 buff->segs[(i*n+j)*3+1] = i*n+j;
87                 buff->segs[(i*n+j)*3+2] = i*n+j+1;
88             }
89             buff->segs[(i*n+j-1)*3+2] = i*n;
90         }
91         for (i = 4; i < 6; i++) {
92             for (j = 0; j < n; j++) {
93                 buff->segs[(i*n+j)*3  ] = c+1;
94                 buff->segs[(i*n+j)*3+1] = (i-4)*n+j;
95                 buff->segs[(i*n+j)*3+2] = (i-2)*n+j;
96             }
97         }
98         if (strstr(option, "x3d")) 
99         {
100             for (i = 6; i < 8; i++) {
101                 for (j = 0; j < n; j++) {
102                     buff->segs[(i*n+j)*3  ] = c;
103                     buff->segs[(i*n+j)*3+1] = 2*(i-6)*n+j;
104                     buff->segs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j;
105                 }
106             }
107         }
108     }
109 //*-* Allocate memory for polygons *-*
110
111     Int_t indx = 0;
112
113     buff->polys = new Int_t[buff->numPolys*6];
114     if (buff->polys) {
115         for (i = 0; i < 2; i++) {
116             for (j = 0; j < n; j++) {
117                 indx = 6*(i*n+j);
118                 buff->polys[indx  ] = c;
119                 buff->polys[indx+1] = 4;
120                 buff->polys[indx+2] = i*n+j;
121                 buff->polys[indx+3] = (4+i)*n+j;
122                 buff->polys[indx+4] = (2+i)*n+j;
123                 buff->polys[indx+5] = (4+i)*n+j+1;
124             }
125             buff->polys[indx+5] = (4+i)*n;
126         }
127         for (i = 2; i < 4; i++) {
128             for (j = 0; j < n; j++) {
129                 indx = 6*(i*n+j);
130                 buff->polys[indx  ] = c+(i-2)*2+1;
131                 buff->polys[indx+1] = 4;
132                 buff->polys[indx+2] = (i-2)*2*n+j;
133                 buff->polys[indx+3] = (4+i)*n+j;
134                 buff->polys[indx+4] = ((i-2)*2+1)*n+j;
135                 buff->polys[indx+5] = (4+i)*n+j+1;
136             }
137             buff->polys[indx+5] = (4+i)*n;
138         }
139     }
140
141     //*-* Paint in the pad
142     Bool_t rangeView = strcmp(option,"range")==0 ? kTRUE : kFALSE;
143     PaintShape(buff,rangeView);
144
145     if (strstr(option, "x3d")) {
146         if(buff && buff->points && buff->segs)
147             FillX3DBuffer(buff);
148         else {
149             gSize3D.numPoints -= buff->numPoints;
150             gSize3D.numSegs   -= buff->numSegs;
151             gSize3D.numPolys  -= buff->numPolys;
152         }
153     }
154
155     if (buff->points)   delete [] buff->points;
156     if (buff->segs)     delete [] buff->segs;
157     if (buff->polys)    delete [] buff->polys;
158     if (buff)           delete    buff;
159 }
160