3 #include "JetPlaneGL.h"
4 #include <Alieve/JetPlane.h>
5 #include <Reve/GLUtilNS.h>
8 #include <TGLSelectRecord.h>
9 #include <TGLIncludes.h>
19 using namespace Alieve;
21 //______________________________________________________________________
27 JetPlaneGL::JetPlaneGL() : TGLObject(), fM(0)
29 fDLCache = kFALSE; // Disable display list -- axis pain.
32 JetPlaneGL::~JetPlaneGL()
35 /**************************************************************************/
37 Bool_t JetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/)
39 if(SetModelCheckClass(obj, Alieve::JetPlane::Class())) {
40 fM = dynamic_cast<JetPlane*>(obj);
46 void JetPlaneGL::SetBBox()
48 // !! This ok if master sub-classed from TAttBBox
49 SetAxisAlignedBBox(((JetPlane*)fExternalObj)->AssertBBox());
52 /**************************************************************************/
54 void JetPlaneGL::DirectDraw(TGLRnrCtx & /*rnrCtx*/) const
57 Float_t minEta = (fM->fMinEta)*(fM->fEtaScale);
58 Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale);
59 Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale);
60 Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale);
61 Float_t phiCoord, etaCoord, dPhi, dEta;
62 Double_t eta, phi, E, x, y;
64 // Show frame for Eta-Phi coordinates
66 glBegin(GL_LINE_LOOP);
67 glVertex3f( minEta, minPhi, 0);
68 glVertex3f( maxEta, minPhi, 0);
69 glVertex3f( maxEta, maxPhi, 0);
70 glVertex3f( minEta, maxPhi, 0);
73 // Show grid in Eta-Phi coordinates
75 dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1);
76 dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1);
78 for (int count=1; count < fM->fNPhiDiv-1; count++)
80 phiCoord = minPhi + count*dPhi;
82 glVertex3f( minEta, phiCoord, 0);
83 glVertex3f( maxEta, phiCoord, 0);
87 for (int count=1; count < fM->fNEtaDiv-1; count++)
89 etaCoord = minEta + count*dEta;
91 glVertex3f( etaCoord, minPhi, 0);
92 glVertex3f( etaCoord, maxPhi, 0);
96 // Show axis tick marks and labels
99 GLUtilNS::GL_Capability_Switch lights_off(GL_LIGHTING, false);
102 ap.SetLineColor(fM->fGridColor);
103 ap.SetTextColor(fM->fGridColor);
104 TGLVector3 start, end;
106 start.Set(minEta, minPhi, 0);
107 end.Set(maxEta, minPhi, 0);
108 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205);
110 start.Set(maxEta, minPhi, 0);
111 end.Set(maxEta, maxPhi, 0);
112 ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205);
116 // Finding the maximum energy
118 std::vector<AliAODTrack>::iterator k = fM->fTracks.begin();
119 std::vector<AliAODJet>::iterator j = fM->fJets.begin();
121 Double_t eJetMax = 0., eTrackMax = 0., eMax;
123 while (j != fM->fJets.end())
125 if (j->E() > eJetMax) eJetMax = j->E();
129 while (k != fM->fTracks.end())
131 if (k->E() > eTrackMax) eTrackMax = k->E();
135 eMax = eJetMax > eTrackMax ? eJetMax : eTrackMax;
137 // Rendering Jets and Tracks in the Eta-Phi plane
139 Int_t nCol = gStyle->GetNumberOfColors();
140 Float_t col[4] = { 0., 0., 0., 0.75};
142 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
143 TGLUtil::SetDrawQuality(6);
149 glEnable(GL_BLEND); // Turn Blending On
150 glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off
154 j = fM->fJets.begin();
156 while (j != fM->fJets.end())
162 x = eta*(fM->fEtaScale);
163 y = phi*(fM->fPhiScale);
165 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*E*
166 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
167 Int_t colIdx = gStyle->GetColorPalette(colBin);
168 TColor* c = gROOT->GetColor(colIdx);
172 col[0] = c->GetRed();
173 col[1] = c->GetGreen();
174 col[2] = c->GetBlue();
178 TGLUtil::DrawLine( TGLVertex3(x,y,0.),
179 TGLVector3(0.,0.,TMath::Log(E + 1.)*fM->fEnergyScale),
180 TGLUtil::kLineHeadArrow, 25.0, col);
191 glDisable(GL_BLEND); // Turn Blending Off
192 glEnable(GL_DEPTH_TEST); // Turn Depth Testing On
196 k = fM->fTracks.begin();
198 while (k != fM->fTracks.end())
206 // printf(" WARNING: Particle with negative energy has been found.\n");
207 // printf(" PARTICLE NOT DISPLAYED. TrackID: %i\n", trackid);
212 x = eta*(fM->fEtaScale);
213 y = phi*(fM->fPhiScale);
215 Int_t colBin = TMath::Min((Int_t) ((nCol-2)*E*
216 TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
217 Int_t colIdx = gStyle->GetColorPalette(colBin);
218 TColor* c = gROOT->GetColor(colIdx);
222 col[0] = c->GetRed();
223 col[1] = c->GetGreen();
224 col[2] = c->GetBlue();
228 TGLUtil::DrawLine( TGLVertex3(x,y,0.),
229 TGLVector3(0.,0.,TMath::Log(E + 1.)*fM->fEnergyScale),
230 TGLUtil::kLineHeadArrow, 5.0, col);
237 TGLUtil::ResetDrawQuality();
243 /**************************************************************************/
245 void JetPlaneGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
247 // printf("beep %u\n", rec.GetN());
249 static Int_t jet1State;
250 static Int_t jet2State;
251 static Int_t track1State;
252 static Int_t track2State;
254 if (fM->fOneSelection)
260 AliAODJet v = fM->fJets[rec.GetItem(1)];
261 printf("Jet 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
262 printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
267 AliAODTrack v = fM->fTracks[rec.GetItem(2)];
268 printf("Track 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());
273 if (fM->fTwoSelection)
276 if ( fM->fSelectionFlag == 1)
280 fM->SetJet1(&(fM->fJets[rec.GetItem(1)]));
287 fM->SetTrack1(&(fM->fTracks[rec.GetItem(1)]));
292 fM->SetSelectionFlag(2);
297 if ( fM->fSelectionFlag == 2)
302 fM->SetJet2(&(fM->fJets[rec.GetItem(1)]));
309 fM->SetTrack2(&(fM->fTracks[rec.GetItem(1)]));
314 printf("Jet: %i, Track: %i \n", jet1State, track1State);
315 printf("Jet: %i, Track: %i \n\n", jet2State, track2State);
317 if(jet1State && jet2State)
319 Double_t Eta1, Eta2, Phi1, Phi2, d;
321 Eta1 = (fM->GetJet1()).Eta();
322 Eta2 = (fM->GetJet2()).Eta();
323 Phi1 = (fM->GetJet1()).Phi();
324 Phi2 = (fM->GetJet2()).Phi();
326 d = TMath::Sqrt(TMath::Power(Eta2-Eta1,2) + TMath::Power(Phi2-Phi1,2));
328 printf("Eta-Phi: %f, %f\n", Eta1, Phi1 );
329 printf("Eta-Phi: %f, %f\n", Eta2, Phi2 );
330 printf("Eta-Phi Distance: %f\n", d);
333 fM->SetSelectionFlag(1);