]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveMUONChamberGL.cxx
corrected treatment of trigger tracks
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveMUONChamberGL.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveMUONChamberGL.h"
11
12 #include <EveDet/AliEveMUONChamber.h>
13 #include <EveDet/AliEveMUONChamberData.h>
14
15 #include <TGLRnrCtx.h>
16 #include <TGLIncludes.h>
17 #include <TMath.h>
18
19
20 //______________________________________________________________________________
21 // AliEveMUONChamberGL
22 //
23
24 ClassImp(AliEveMUONChamberGL)
25
26 //______________________________________________________________________________
27 AliEveMUONChamberGL::AliEveMUONChamberGL() :
28   TGLObject(),
29   fChamber(0),
30   fQS1(), fQS2(),
31   fRTS(0)
32 {
33   //
34   // constructor
35   //
36
37 }
38
39 //______________________________________________________________________________
40 AliEveMUONChamberGL::~AliEveMUONChamberGL()
41 {
42   //
43   // destructor
44   //
45
46 }
47
48 //______________________________________________________________________________
49 Bool_t AliEveMUONChamberGL::SetModel(TObject* obj, const Option_t* /*opt*/)
50 {
51   //
52   // ...
53   //
54
55   if(SetModelCheckClass(obj, AliEveMUONChamber::Class())) {
56
57     fChamber = (AliEveMUONChamber*) fExternalObj;
58     fQS1.SetModel(&fChamber->fQuadSet1);
59     fQS2.SetModel(&fChamber->fQuadSet2);
60     return kTRUE;
61
62   }
63
64   return kFALSE;
65
66 }
67
68 //______________________________________________________________________________
69 void AliEveMUONChamberGL::SetBBox()
70 {
71   //
72   // ...
73   //
74
75   SetAxisAlignedBBox(((AliEveMUONChamber*)fExternalObj)->AssertBBox());
76
77 }
78
79 //______________________________________________________________________________
80 void AliEveMUONChamberGL::DirectDraw(TGLRnrCtx& rnrCtx) const
81 {
82   //
83   // Actual GL drawing.
84   //
85
86   glDisable(GL_LIGHTING);
87
88   //Double_t width = 10;
89   //glOrtho(-width,+width,-width,+width,-width,+width);
90
91   if(fRTS < fChamber->fRTS) {
92     fChamber->UpdateQuads();
93     fRTS = fChamber->fRTS;
94   }
95
96   Bool_t hasData = (fChamber->GetChamberData() != 0);
97
98   if(hasData) {
99
100     DrawQuads(rnrCtx);
101     DrawPoints();
102
103   }
104
105   DrawChamberFrame();
106
107 }
108
109 //______________________________________________________________________________
110 void AliEveMUONChamberGL::DrawQuads(TGLRnrCtx& rnrCtx) const
111 {
112   //
113   // draw the digits as GL_QUADS
114   //
115
116   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
117
118   glDisable(GL_LIGHTING);
119   glDisable(GL_CULL_FACE);
120
121   //Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
122
123   glPolygonMode(GL_FRONT, GL_FILL);
124   glPolygonMode(GL_BACK,  GL_LINE);
125
126   fQS1.DirectDraw(rnrCtx);
127
128   glPolygonMode(GL_FRONT, GL_LINE);
129   glPolygonMode(GL_BACK,  GL_FILL);
130
131   fQS2.DirectDraw(rnrCtx);
132
133   glPopAttrib();
134
135 }
136
137 //______________________________________________________________________________
138 void AliEveMUONChamberGL::DrawPoints() const
139 {
140   //
141   // draw the clusters as GL_QUADS
142   //
143
144   Float_t x, y, z;
145
146   glDisable(GL_LIGHTING);
147   glLineWidth(1.0);
148
149   TGLUtil::Color3f(1.0,1.0,1.0);
150
151   glBegin(GL_LINES);
152
153   // clusters
154
155   Int_t clsSize = fChamber->fClusterSize;
156
157   if (clsSize > 1) {
158
159     for (Int_t i = 0; i < fChamber->fPointSet1.GetN(); i++) {
160
161       fChamber->fPointSet1.GetPoint(i,x,y,z);
162
163       glVertex3f(x-clsSize,y+clsSize,z);
164       glVertex3f(x+clsSize,y-clsSize,z);
165
166       glVertex3f(x-clsSize,y-clsSize,z);
167       glVertex3f(x+clsSize,y+clsSize,z);
168
169     }
170
171   }
172
173   // hits
174
175   Int_t hitSize = fChamber->fHitSize;
176
177   if (hitSize > 1) {
178
179     for (Int_t i = 0; i < fChamber->fPointSet2.GetN(); i++) {
180
181       fChamber->fPointSet2.GetPoint(i,x,y,z);
182
183       glVertex3f(x-hitSize,y,z);
184       glVertex3f(x+hitSize,y,z);
185
186       glVertex3f(x,y-hitSize,z);
187       glVertex3f(x,y+hitSize,z);
188
189     }
190
191   }
192
193   glEnd();
194
195 }
196
197 //______________________________________________________________________________
198 void AliEveMUONChamberGL::DrawChamberFrame() const
199 {
200   //
201   // draw the chamber frame as GL_LINE_LOOP
202   //
203
204   AliEveMUONChamberData* chamberData = fChamber->GetChamberData();
205   Int_t nDetElem = chamberData->GetNDetElem();
206   Float_t *frameCoord;
207   Float_t xOrig, yOrig, xRad, yRad, x, y, z;
208
209   TGLUtil::Color4ub(255, 0, 0, 255);
210
211   for (Int_t id = 0; id < nDetElem; id++) {
212
213     frameCoord = chamberData->GetFrameCoord(id);
214
215     if (fChamber->GetID() < 4) {
216
217       xOrig = frameCoord[0];
218       yOrig = frameCoord[1];
219       xRad  = frameCoord[2];
220       yRad  = frameCoord[3];
221       z     = frameCoord[4];
222
223       if (fChamber->GetID() < 2) {
224         xRad += TMath::Sign(15.0,(Double_t)xRad);
225         yRad += TMath::Sign(15.0,(Double_t)yRad);
226       } else {
227         xRad += TMath::Sign( 5.0,(Double_t)xRad);
228         yRad += TMath::Sign( 5.0,(Double_t)yRad);
229       }
230
231       glBegin(GL_LINE_LOOP);
232
233       glVertex3f(xOrig,yOrig,z);
234
235       Int_t nstep = 100;
236       Float_t dstep = TMath::Pi()/2.0 / (Float_t)nstep;
237       Float_t d;
238       for (Int_t istep = 0; istep < nstep; istep++) {
239
240         d = istep * dstep;
241         x = xOrig + xRad * TMath::Cos(d);
242         y = yOrig + yRad * TMath::Sin(d);
243
244         glVertex3f(x,y,z);
245
246       }
247
248       glVertex3f(xOrig,yOrig,z);
249
250       glEnd();
251
252     } else {
253
254       glBegin(GL_LINE_LOOP);
255       glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]);
256       glVertex3f(frameCoord[0],frameCoord[3],frameCoord[4]);
257       glVertex3f(frameCoord[2],frameCoord[3],frameCoord[4]);
258       glVertex3f(frameCoord[2],frameCoord[1],frameCoord[4]);
259       glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]);
260       glEnd();
261
262     }
263
264   }
265
266 }