]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 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 "AliEveJetPlaneGL.h" | |
11 | #include "AliEveJetPlane.h" | |
12 | ||
13 | #include <TGLRnrCtx.h> | |
14 | #include <TGLSelectRecord.h> | |
15 | #include <TGLIncludes.h> | |
16 | ||
17 | #include "TGLUtil.h" | |
18 | #include "TGLAxis.h" | |
19 | ||
20 | #include <TColor.h> | |
21 | #include <TStyle.h> | |
22 | #include <TROOT.h> | |
23 | ||
24 | ||
25 | //______________________________________________________________________________ | |
26 | // | |
27 | // GL renderer for AliEveJetPlane. | |
28 | ||
29 | ClassImp(AliEveJetPlaneGL) | |
30 | ||
31 | AliEveJetPlaneGL::AliEveJetPlaneGL() : TGLObject(), fM(0) | |
32 | { | |
33 | // Constructor. | |
34 | ||
35 | fDLCache = kFALSE; // Disable display list -- axis pain. | |
36 | } | |
37 | ||
38 | /******************************************************************************/ | |
39 | ||
40 | Bool_t AliEveJetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/) | |
41 | { | |
42 | // Set model object. | |
43 | ||
44 | if(SetModelCheckClass(obj, AliEveJetPlane::Class())) { | |
45 | fM = dynamic_cast<AliEveJetPlane*>(obj); | |
46 | return kTRUE; | |
47 | } | |
48 | return kFALSE; | |
49 | } | |
50 | ||
51 | void AliEveJetPlaneGL::SetBBox() | |
52 | { | |
53 | // Set bounding box. | |
54 | ||
55 | SetAxisAlignedBBox(((AliEveJetPlane*)fExternalObj)->AssertBBox()); | |
56 | } | |
57 | ||
58 | /******************************************************************************/ | |
59 | ||
60 | void AliEveJetPlaneGL::DirectDraw(TGLRnrCtx & /*rnrCtx*/) const | |
61 | { | |
62 | // Render the object. | |
63 | ||
64 | Float_t minEta = (fM->fMinEta)*(fM->fEtaScale); | |
65 | Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale); | |
66 | Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale); | |
67 | Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale); | |
68 | Float_t phiCoord, etaCoord, dPhi, dEta; | |
69 | Double_t eta, phi, e, x, y; | |
70 | ||
71 | // Show frame for Eta-Phi coordinates | |
72 | ||
73 | glBegin(GL_LINE_LOOP); | |
74 | glVertex3f( minEta, minPhi, 0); | |
75 | glVertex3f( maxEta, minPhi, 0); | |
76 | glVertex3f( maxEta, maxPhi, 0); | |
77 | glVertex3f( minEta, maxPhi, 0); | |
78 | glEnd(); | |
79 | ||
80 | // Show grid in Eta-Phi coordinates | |
81 | ||
82 | dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1); | |
83 | dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1); | |
84 | ||
85 | for (int count=1; count < fM->fNPhiDiv-1; count++) | |
86 | { | |
87 | phiCoord = minPhi + count*dPhi; | |
88 | glBegin(GL_LINES); | |
89 | glVertex3f( minEta, phiCoord, 0); | |
90 | glVertex3f( maxEta, phiCoord, 0); | |
91 | glEnd(); | |
92 | } | |
93 | ||
94 | for (int count=1; count < fM->fNEtaDiv-1; count++) | |
95 | { | |
96 | etaCoord = minEta + count*dEta; | |
97 | glBegin(GL_LINES); | |
98 | glVertex3f( etaCoord, minPhi, 0); | |
99 | glVertex3f( etaCoord, maxPhi, 0); | |
100 | glEnd(); | |
101 | } | |
102 | ||
103 | // Show axis tick marks and labels | |
104 | ||
105 | { | |
106 | TGLCapabilitySwitch lights_off(GL_LIGHTING, false); | |
107 | ||
108 | TGLAxis ap; | |
109 | ap.SetLineColor(fM->fGridColor); | |
110 | ap.SetTextColor(fM->fGridColor); | |
111 | TGLVector3 start, end; | |
112 | ||
113 | start.Set(minEta, minPhi, 0); | |
114 | end.Set(maxEta, minPhi, 0); | |
115 | ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205); | |
116 | ||
117 | start.Set(maxEta, minPhi, 0); | |
118 | end.Set(maxEta, maxPhi, 0); | |
119 | ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205); | |
120 | ||
121 | } | |
122 | ||
123 | // Finding the maximum energy | |
124 | ||
125 | std::vector<AliAODTrack>::iterator k = fM->fTracks.begin(); | |
126 | std::vector<AliAODJet>::iterator j = fM->fJets.begin(); | |
127 | ||
128 | Double_t eJetMax = 0., eTrackMax = 0., eMax; | |
129 | ||
130 | while (j != fM->fJets.end()) | |
131 | { | |
132 | if (j->E() > eJetMax) eJetMax = j->E(); | |
133 | ++j; | |
134 | } | |
135 | ||
136 | while (k != fM->fTracks.end()) | |
137 | { | |
138 | if (k->E() > eTrackMax) eTrackMax = k->E(); | |
139 | ++k; | |
140 | } | |
141 | ||
142 | eMax = eJetMax > eTrackMax ? eJetMax : eTrackMax; | |
143 | ||
144 | // Rendering Jets and Tracks in the Eta-Phi plane | |
145 | ||
146 | Int_t nCol = gStyle->GetNumberOfColors(); | |
147 | Float_t col[4] = { 0., 0., 0., 0.75}; | |
148 | ||
149 | glBlendFunc(GL_SRC_ALPHA,GL_ONE); | |
150 | TGLUtil::SetDrawQuality(6); | |
151 | ||
152 | ||
153 | glPushName(0); | |
154 | if (fM->fRnrJets) | |
155 | { | |
156 | glEnable(GL_BLEND); // Turn Blending On | |
157 | glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off | |
158 | UInt_t jetid = 0; | |
159 | ||
160 | ||
161 | j = fM->fJets.begin(); | |
162 | ||
163 | while (j != fM->fJets.end()) | |
164 | { | |
165 | eta = j->Eta(); | |
166 | phi = j->Phi(); | |
167 | e = j->E(); | |
168 | ||
169 | x = eta*(fM->fEtaScale); | |
170 | y = phi*(fM->fPhiScale); | |
171 | ||
172 | Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e* | |
173 | TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2); | |
174 | Int_t colIdx = gStyle->GetColorPalette(colBin); | |
175 | TColor* c = gROOT->GetColor(colIdx); | |
176 | ||
177 | if(c) | |
178 | { | |
179 | col[0] = c->GetRed(); | |
180 | col[1] = c->GetGreen(); | |
181 | col[2] = c->GetBlue(); | |
182 | } | |
183 | ||
184 | glLoadName(jetid); | |
185 | TGLUtil::DrawLine(TGLVertex3(x,y,0.), | |
186 | TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale), | |
187 | TGLUtil::kLineHeadArrow, 25.0, col); | |
188 | ++j; ++jetid; | |
189 | } | |
190 | } | |
191 | ||
192 | col[3] = 1.0; | |
193 | ||
194 | glPushName(1); | |
195 | if(fM->fRnrTracks) | |
196 | { | |
197 | glDisable(GL_BLEND); // Turn Blending Off | |
198 | glEnable(GL_DEPTH_TEST); // Turn Depth Testing On | |
199 | UInt_t trackid = 0; | |
200 | ||
201 | k = fM->fTracks.begin(); | |
202 | ||
203 | while (k != fM->fTracks.end()) | |
204 | { | |
205 | eta = k->Eta(); | |
206 | phi = k->Phi(); | |
207 | e = k->E(); | |
208 | ||
209 | if (e < 0.) | |
210 | { | |
211 | // printf(" WARNING: Particle with negative energy has been found.\n"); | |
212 | // printf(" PARTICLE NOT DISPLAYED. TrackID: %i\n", trackid); | |
213 | ++k; ++trackid; | |
214 | continue; | |
215 | } | |
216 | ||
217 | x = eta*(fM->fEtaScale); | |
218 | y = phi*(fM->fPhiScale); | |
219 | ||
220 | Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e* | |
221 | TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2); | |
222 | Int_t colIdx = gStyle->GetColorPalette(colBin); | |
223 | TColor* c = gROOT->GetColor(colIdx); | |
224 | ||
225 | if(c) | |
226 | { | |
227 | col[0] = c->GetRed(); | |
228 | col[1] = c->GetGreen(); | |
229 | col[2] = c->GetBlue(); | |
230 | } | |
231 | ||
232 | glLoadName(trackid); | |
233 | TGLUtil::DrawLine( TGLVertex3(x,y,0.), | |
234 | TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale), | |
235 | TGLUtil::kLineHeadArrow, 5.0, col); | |
236 | ||
237 | ++k; ++trackid; | |
238 | } | |
239 | } | |
240 | ||
241 | glPopName(); | |
242 | TGLUtil::ResetDrawQuality(); | |
243 | } | |
244 | ||
245 | /******************************************************************************/ | |
246 | ||
247 | void AliEveJetPlaneGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec) | |
248 | { | |
249 | // Process selection and print jet information. | |
250 | ||
251 | // printf("beep %u\n", rec.GetN()); | |
252 | // rec.Print(); | |
253 | static Int_t jet1State; | |
254 | static Int_t jet2State; | |
255 | static Int_t track1State; | |
256 | static Int_t track2State; | |
257 | ||
258 | if (fM->fOneSelection) | |
259 | { | |
260 | printf("\n"); | |
261 | ||
262 | if (rec.GetN() == 2) | |
263 | { | |
264 | AliAODJet v = fM->fJets[rec.GetItem(1)]; | |
265 | printf("Jet 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() ); | |
266 | printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi()); | |
267 | } | |
268 | ||
269 | if (rec.GetN() == 3) | |
270 | { | |
271 | AliAODTrack v = fM->fTracks[rec.GetItem(2)]; | |
272 | printf("TEveTrack 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() ); | |
273 | printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi()); | |
274 | } | |
275 | } | |
276 | ||
277 | if (fM->fTwoSelection) | |
278 | { | |
279 | ||
280 | if ( fM->fSelectionFlag == 1) | |
281 | { | |
282 | if (rec.GetN() == 2) | |
283 | { | |
284 | fM->SetJet1(&(fM->fJets[rec.GetItem(1)])); | |
285 | jet1State = 1; | |
286 | track1State = 0; | |
287 | } | |
288 | ||
289 | if (rec.GetN() == 3) | |
290 | { | |
291 | fM->SetTrack1(&(fM->fTracks[rec.GetItem(1)])); | |
292 | jet1State = 0; | |
293 | track1State = 1; | |
294 | } | |
295 | ||
296 | fM->SetSelectionFlag(2); | |
297 | ||
298 | return; | |
299 | } | |
300 | ||
301 | if ( fM->fSelectionFlag == 2) | |
302 | { | |
303 | printf("\n"); | |
304 | if (rec.GetN() == 2) | |
305 | { | |
306 | fM->SetJet2(&(fM->fJets[rec.GetItem(1)])); | |
307 | jet2State = 1; | |
308 | track2State = 0; | |
309 | } | |
310 | ||
311 | if (rec.GetN() == 3) | |
312 | { | |
313 | fM->SetTrack2(&(fM->fTracks[rec.GetItem(1)])); | |
314 | jet2State = 0; | |
315 | track2State = 1; | |
316 | } | |
317 | ||
318 | printf("Jet: %i, TEveTrack: %i \n", jet1State, track1State); | |
319 | printf("Jet: %i, TEveTrack: %i \n\n", jet2State, track2State); | |
320 | ||
321 | if(jet1State && jet2State) | |
322 | { | |
323 | Double_t eta1, eta2, phi1, phi2, d; | |
324 | ||
325 | eta1 = (fM->GetJet1()).Eta(); | |
326 | eta2 = (fM->GetJet2()).Eta(); | |
327 | phi1 = (fM->GetJet1()).Phi(); | |
328 | phi2 = (fM->GetJet2()).Phi(); | |
329 | ||
330 | d = TMath::Sqrt(TMath::Power(eta2-eta1,2) + TMath::Power(phi2-phi1,2)); | |
331 | ||
332 | printf("Eta-Phi: %f, %f\n", eta1, phi1); | |
333 | printf("Eta-Phi: %f, %f\n", eta2, phi2); | |
334 | printf("Eta-Phi Distance: %f\n", d); | |
335 | } | |
336 | ||
337 | fM->SetSelectionFlag(1); | |
338 | } | |
339 | ||
340 | } | |
341 | ||
342 | } | |
343 | ||
344 | ||
345 | ||
346 |