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 <TGLRnrCtx.h>
14 #include <TGLSelectRecord.h>
15 #include <TGLIncludes.h>
24 //==============================================================================
25 //==============================================================================
27 //==============================================================================
29 //______________________________________________________________________________
31 // GL renderer for AliEveJetPlane.
33 ClassImp(AliEveJetPlaneGL)
35 AliEveJetPlaneGL::AliEveJetPlaneGL() : TGLObject(), fM(0)
39 fDLCache = kFALSE; // Disable display list -- axis pain.
42 /******************************************************************************/
44 Bool_t AliEveJetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/)
48 if(SetModelCheckClass(obj, AliEveJetPlane::Class())) {
49 fM = dynamic_cast<AliEveJetPlane*>(obj);
55 void AliEveJetPlaneGL::SetBBox()
59 SetAxisAlignedBBox(((AliEveJetPlane*)fExternalObj)->AssertBBox());
62 /******************************************************************************/
64 void AliEveJetPlaneGL::DirectDraw(TGLRnrCtx& rnrCtx) const
68 Float_t minEta = (fM->fMinEta)*(fM->fEtaScale);
69 Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale);
70 Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale) - 350;
71 Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale) - 350;
72 Float_t phiCoord, etaCoord, dPhi, dEta;
73 Double_t eta, phi, e, x, y;
75 // Show frame for Eta-Phi coordinates
77 glBegin(GL_LINE_LOOP);
78 glVertex3f(minEta, minPhi, 0);
79 glVertex3f(maxEta, minPhi, 0);
80 glVertex3f(maxEta, maxPhi, 0);
81 glVertex3f(minEta, maxPhi, 0);
84 if (rnrCtx.Selection() == kFALSE && rnrCtx.Highlight() == kFALSE)
87 // Show grid in Eta-Phi coordinates
89 dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1);
90 dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1);
92 for (Int_t count = 1; count < fM->fNPhiDiv-1; ++count)
94 phiCoord = minPhi + count*dPhi;
96 glVertex3f( minEta, phiCoord, 0);
97 glVertex3f( maxEta, phiCoord, 0);
101 for (Int_t count = 1; count < fM->fNEtaDiv-1; ++count)
103 etaCoord = minEta + count*dEta;
105 glVertex3f(etaCoord, minPhi, 0);
106 glVertex3f(etaCoord, maxPhi, 0);
110 // Show axis tick marks and labels
113 TGLCapabilitySwitch lightsOff(GL_LIGHTING, false);
116 ap.SetLineColor(fM->fGridColor);
117 ap.SetTextColor(fM->fGridColor);
118 TGLVector3 start, end;
120 start.Set(minEta, minPhi, 0);
121 end.Set(maxEta, minPhi, 0);
122 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205);
124 start.Set(maxEta, minPhi, 0);
125 end.Set(maxEta, maxPhi, 0);
126 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205);
131 // Finding the maximum energy
133 std::vector<AliAODTrack>::iterator k = fM->fTracks.begin();
134 std::vector<AliAODJet>::iterator j = fM->fJets.begin();
136 Double_t eJetMax = 0., eTrackMax = 0., eMax;
138 while (j != fM->fJets.end())
140 if (j->E() > eJetMax) eJetMax = j->E();
144 while (k != fM->fTracks.end())
146 if (k->E() > eTrackMax) eTrackMax = k->E();
150 eMax = eJetMax > eTrackMax ? eJetMax : eTrackMax;
152 // Rendering Jets and Tracks in the Eta-Phi plane
154 Int_t nCol = gStyle->GetNumberOfColors();
155 Float_t col[4] = { 0., 0., 0., 0.75};
157 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
158 TGLUtil::SetDrawQuality(6);
164 glEnable(GL_BLEND); // Turn Blending On
165 glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off
169 j = fM->fJets.begin();
171 while (j != fM->fJets.end())
177 x = eta*(fM->fEtaScale);
178 y = phi*(fM->fPhiScale) - 350;
180 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e*
181 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
182 Int_t colIdx = gStyle->GetColorPalette(colBin);
183 TColor* c = gROOT->GetColor(colIdx);
187 col[0] = c->GetRed();
188 col[1] = c->GetGreen();
189 col[2] = c->GetBlue();
193 TGLUtil::DrawLine(TGLVertex3(x,y,0.),
194 TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale),
195 TGLUtil::kLineHeadArrow, 25.0, col);
205 glDisable(GL_BLEND); // Turn Blending Off
206 glEnable(GL_DEPTH_TEST); // Turn Depth Testing On
209 k = fM->fTracks.begin();
211 while (k != fM->fTracks.end())
219 // printf(" WARNING: Particle with negative energy has been found.\n");
220 // printf(" PARTICLE NOT DISPLAYED. TrackID: %i\n", trackid);
225 x = eta*(fM->fEtaScale);
226 y = phi*(fM->fPhiScale) - 350;
228 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*e*
229 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
230 Int_t colIdx = gStyle->GetColorPalette(colBin);
231 TColor* c = gROOT->GetColor(colIdx);
235 col[0] = c->GetRed();
236 col[1] = c->GetGreen();
237 col[2] = c->GetBlue();
241 TGLUtil::DrawLine( TGLVertex3(x,y,0.),
242 TGLVector3(0.,0.,TMath::Log(e + 1.)*fM->fEnergyScale),
243 TGLUtil::kLineHeadArrow, 5.0, col);
250 TGLUtil::ResetDrawQuality();
253 /******************************************************************************/
255 void AliEveJetPlaneGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
257 // Process selection and print jet information.
259 // printf("beep %u\n", rec.GetN());
261 static Int_t jet1State;
262 static Int_t jet2State;
263 static Int_t track1State;
264 static Int_t track2State;
266 if (fM->fOneSelection)
272 AliAODJet v = fM->fJets[rec.GetItem(1)];
273 printf("Jet 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
274 printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
279 AliAODTrack v = fM->fTracks[rec.GetItem(2)];
280 printf("TEveTrack 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
281 printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
285 if (fM->fTwoSelection)
288 if ( fM->fSelectionFlag == 1)
292 fM->SetJet1(&(fM->fJets[rec.GetItem(1)]));
299 fM->SetTrack1(&(fM->fTracks[rec.GetItem(1)]));
304 fM->SetSelectionFlag(2);
309 if ( fM->fSelectionFlag == 2)
314 fM->SetJet2(&(fM->fJets[rec.GetItem(1)]));
321 fM->SetTrack2(&(fM->fTracks[rec.GetItem(1)]));
326 printf("Jet: %i, TEveTrack: %i \n", jet1State, track1State);
327 printf("Jet: %i, TEveTrack: %i \n\n", jet2State, track2State);
329 if(jet1State && jet2State)
331 Double_t eta1, eta2, phi1, phi2, d;
333 eta1 = (fM->GetJet1()).Eta();
334 eta2 = (fM->GetJet2()).Eta();
335 phi1 = (fM->GetJet1()).Phi();
336 phi2 = (fM->GetJet2()).Phi();
338 d = TMath::Sqrt(TMath::Power(eta2-eta1,2) + TMath::Power(phi2-phi1,2));
340 printf("Eta-Phi: %f, %f\n", eta1, phi1);
341 printf("Eta-Phi: %f, %f\n", eta2, phi2);
342 printf("Eta-Phi Distance: %f\n", d);
345 fM->SetSelectionFlag(1);