2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 #include "AliEveJetPlaneGL.h"
11 #include "AliEveJetPlane.h"
13 #include <TGLSelectRecord.h>
14 #include <TGLIncludes.h>
23 //==============================================================================
24 //==============================================================================
26 //==============================================================================
28 //______________________________________________________________________________
30 // GL renderer for AliEveJetPlane.
32 ClassImp(AliEveJetPlaneGL)
34 AliEveJetPlaneGL::AliEveJetPlaneGL() : TGLObject(), fM(0)
38 fDLCache = kFALSE; // Disable display list -- axis pain.
41 /******************************************************************************/
43 Bool_t AliEveJetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/)
47 if(SetModelCheckClass(obj, AliEveJetPlane::Class())) {
48 fM = dynamic_cast<AliEveJetPlane*>(obj);
54 void AliEveJetPlaneGL::SetBBox()
58 SetAxisAlignedBBox(((AliEveJetPlane*)fExternalObj)->AssertBBox());
61 /******************************************************************************/
63 void AliEveJetPlaneGL::DirectDraw(TGLRnrCtx & /*rnrCtx*/) const
67 Float_t minEta = (fM->fMinEta)*(fM->fEtaScale);
68 Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale);
69 Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale);
70 Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale);
71 Float_t phiCoord, etaCoord, dPhi, dEta;
72 Double_t eta, phi, e, x, y;
74 // Show frame for Eta-Phi coordinates
76 glBegin(GL_LINE_LOOP);
77 glVertex3f(minEta, minPhi, 0);
78 glVertex3f(maxEta, minPhi, 0);
79 glVertex3f(maxEta, maxPhi, 0);
80 glVertex3f(minEta, maxPhi, 0);
83 // Show grid in Eta-Phi coordinates
85 dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1);
86 dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1);
88 for (Int_t count = 1; count < fM->fNPhiDiv-1; ++count)
90 phiCoord = minPhi + count*dPhi;
92 glVertex3f( minEta, phiCoord, 0);
93 glVertex3f( maxEta, phiCoord, 0);
97 for (Int_t count = 1; count < fM->fNEtaDiv-1; ++count)
99 etaCoord = minEta + count*dEta;
101 glVertex3f(etaCoord, minPhi, 0);
102 glVertex3f(etaCoord, maxPhi, 0);
106 // Show axis tick marks and labels
109 TGLCapabilitySwitch lightsOff(GL_LIGHTING, false);
112 ap.SetLineColor(fM->fGridColor);
113 ap.SetTextColor(fM->fGridColor);
114 TGLVector3 start, end;
116 start.Set(minEta, minPhi, 0);
117 end.Set(maxEta, minPhi, 0);
118 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205);
120 start.Set(maxEta, minPhi, 0);
121 end.Set(maxEta, maxPhi, 0);
122 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205);
126 // Finding the maximum energy
128 std::vector<AliAODTrack>::iterator k = fM->fTracks.begin();
129 std::vector<AliAODJet>::iterator j = fM->fJets.begin();
131 Double_t eJetMax = 0., eTrackMax = 0., eMax;
133 while (j != fM->fJets.end())
135 if (j->E() > eJetMax) eJetMax = j->E();
139 while (k != fM->fTracks.end())
141 if (k->E() > eTrackMax) eTrackMax = k->E();
145 eMax = eJetMax > eTrackMax ? eJetMax : eTrackMax;
147 // Rendering Jets and Tracks in the Eta-Phi plane
149 Int_t nCol = gStyle->GetNumberOfColors();
150 Float_t col[4] = { 0., 0., 0., 0.75};
152 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
153 TGLUtil::SetDrawQuality(6);
159 glEnable(GL_BLEND); // Turn Blending On
160 glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off
164 j = fM->fJets.begin();
166 while (j != fM->fJets.end())
172 x = eta*(fM->fEtaScale);
173 y = phi*(fM->fPhiScale);
175 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e*
176 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
177 Int_t colIdx = gStyle->GetColorPalette(colBin);
178 TColor* c = gROOT->GetColor(colIdx);
182 col[0] = c->GetRed();
183 col[1] = c->GetGreen();
184 col[2] = c->GetBlue();
188 TGLUtil::DrawLine(TGLVertex3(x,y,0.),
189 TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale),
190 TGLUtil::kLineHeadArrow, 25.0, col);
200 glDisable(GL_BLEND); // Turn Blending Off
201 glEnable(GL_DEPTH_TEST); // Turn Depth Testing On
204 k = fM->fTracks.begin();
206 while (k != fM->fTracks.end())
214 // printf(" WARNING: Particle with negative energy has been found.\n");
215 // printf(" PARTICLE NOT DISPLAYED. TrackID: %i\n", trackid);
220 x = eta*(fM->fEtaScale);
221 y = phi*(fM->fPhiScale);
223 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e*
224 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
225 Int_t colIdx = gStyle->GetColorPalette(colBin);
226 TColor* c = gROOT->GetColor(colIdx);
230 col[0] = c->GetRed();
231 col[1] = c->GetGreen();
232 col[2] = c->GetBlue();
236 TGLUtil::DrawLine( TGLVertex3(x,y,0.),
237 TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale),
238 TGLUtil::kLineHeadArrow, 5.0, col);
245 TGLUtil::ResetDrawQuality();
248 /******************************************************************************/
250 void AliEveJetPlaneGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
252 // Process selection and print jet information.
254 // printf("beep %u\n", rec.GetN());
256 static Int_t jet1State;
257 static Int_t jet2State;
258 static Int_t track1State;
259 static Int_t track2State;
261 if (fM->fOneSelection)
267 AliAODJet v = fM->fJets[rec.GetItem(1)];
268 printf("Jet 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
269 printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
274 AliAODTrack v = fM->fTracks[rec.GetItem(2)];
275 printf("TEveTrack 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
276 printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
280 if (fM->fTwoSelection)
283 if ( fM->fSelectionFlag == 1)
287 fM->SetJet1(&(fM->fJets[rec.GetItem(1)]));
294 fM->SetTrack1(&(fM->fTracks[rec.GetItem(1)]));
299 fM->SetSelectionFlag(2);
304 if ( fM->fSelectionFlag == 2)
309 fM->SetJet2(&(fM->fJets[rec.GetItem(1)]));
316 fM->SetTrack2(&(fM->fTracks[rec.GetItem(1)]));
321 printf("Jet: %i, TEveTrack: %i \n", jet1State, track1State);
322 printf("Jet: %i, TEveTrack: %i \n\n", jet2State, track2State);
324 if(jet1State && jet2State)
326 Double_t eta1, eta2, phi1, phi2, d;
328 eta1 = (fM->GetJet1()).Eta();
329 eta2 = (fM->GetJet2()).Eta();
330 phi1 = (fM->GetJet1()).Phi();
331 phi2 = (fM->GetJet2()).Phi();
333 d = TMath::Sqrt(TMath::Power(eta2-eta1,2) + TMath::Power(phi2-phi1,2));
335 printf("Eta-Phi: %f, %f\n", eta1, phi1);
336 printf("Eta-Phi: %f, %f\n", eta2, phi2);
337 printf("Eta-Phi Distance: %f\n", d);
340 fM->SetSelectionFlag(1);