From Cesar: First version of jet visualization code.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Aug 2007 14:29:50 +0000 (14:29 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Aug 2007 14:29:50 +0000 (14:29 +0000)
EVE/Alieve/JetPlane.cxx [new file with mode: 0644]
EVE/Alieve/JetPlane.h [new file with mode: 0644]
EVE/Alieve/JetPlaneEditor.cxx [new file with mode: 0644]
EVE/Alieve/JetPlaneEditor.h [new file with mode: 0644]
EVE/Alieve/JetPlaneGL.cxx [new file with mode: 0644]
EVE/Alieve/JetPlaneGL.h [new file with mode: 0644]

diff --git a/EVE/Alieve/JetPlane.cxx b/EVE/Alieve/JetPlane.cxx
new file mode 100644 (file)
index 0000000..fb41da5
--- /dev/null
@@ -0,0 +1,96 @@
+// $Header$
+
+#include "JetPlane.h"
+#include <TString.h>
+#include <TBuffer3D.h>
+#include <TBuffer3DTypes.h>
+#include <TVirtualPad.h>
+#include <TVirtualViewer3D.h>
+
+using namespace Alieve;
+
+//______________________________________________________________________
+// JetPlane
+//
+
+
+Bool_t JetPlane::fgOneMomentumXYZ      = kFALSE;
+Bool_t JetPlane::fgOneMomentumPhiTheta = kFALSE;
+Bool_t JetPlane::fgOneEta     = kFALSE;
+Bool_t JetPlane::fgOneE       = kFALSE;
+Bool_t JetPlane::fgOneChgMass = kFALSE;
+
+
+ClassImp(JetPlane)
+
+JetPlane::JetPlane(Int_t iev) :
+  RenderElementList(Form("JetPlane %i",iev), Form("%i",iev)),
+
+  fMinEta (-1.5 ),
+  fMaxEta ( 1.5 ),
+  fMinPhi (-TMath::Pi() ),
+  fMaxPhi ( TMath::Pi() ),
+
+  fNEtaDiv(30),
+  fNPhiDiv(30),
+
+  fEtaScale(350/1.5),
+  fPhiScale(350/TMath::Pi()),
+  fEnergyScale(100.0),
+
+  fEnergyColorScale (0.),
+
+  fGridColor(5),
+
+  fRnrJets (kTRUE),
+  fRnrTracks (kTRUE),
+
+  fOneSelection (kTRUE),
+  fTwoSelection (kFALSE),
+
+  fSelectionFlag (1)
+{
+  SetMainColorPtr(&fGridColor);
+}
+
+/**************************************************************************/
+
+void JetPlane::AddJet(AliAODJet jet)
+{
+  fJets.push_back(jet);
+}
+
+/**************************************************************************/
+
+void JetPlane::AddTrack(AliAODTrack track)
+{
+  fTracks.push_back(track);
+}
+
+
+/**************************************************************************/
+
+void JetPlane::ComputeBBox()
+{
+  BBoxInit();
+  BBoxCheckPoint(-350, -350, -20);
+  BBoxCheckPoint( 350,  350,  20);
+}
+
+void JetPlane::Paint(Option_t* /*option*/)
+{
+  TBuffer3D buff(TBuffer3DTypes::kGeneric);
+
+  // Section kCore
+  buff.fID           = this;
+  buff.fColor        = fGridColor;
+  buff.fTransparency = 0;
+  fHMTrans.SetBuffer3D(buff);
+  buff.SetSectionsValid(TBuffer3D::kCore);
+
+  Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
+  if (reqSections == TBuffer3D::kNone) {
+    // printf("JetPlane::Paint viewer was happy with Core buff3d.\n");
+    return;
+  }
+}
diff --git a/EVE/Alieve/JetPlane.h b/EVE/Alieve/JetPlane.h
new file mode 100644 (file)
index 0000000..d6347a3
--- /dev/null
@@ -0,0 +1,126 @@
+// $Header$
+
+#ifndef ALIEVE_JetPlane_H
+#define ALIEVE_JetPlane_H
+
+#include <Reve/Reve.h>
+#include <Reve/RenderElement.h>
+#include <Reve/ZTrans.h>
+
+#include <TAtt3D.h>
+#include <TAttBBox.h>
+
+#include <AliAODJet.h>
+#include <AliAODTrack.h>
+
+#include <vector>
+
+namespace Alieve {
+
+class JetPlane : public Reve::RenderElementList,
+                             public TAtt3D,
+                             public TAttBBox
+{
+  friend class JetPlaneGL;
+
+private:
+  JetPlane(const JetPlane&);            // Not implemented
+  JetPlane& operator=(const JetPlane&); // Not implemented
+
+protected:
+  Float_t fMinEta;
+  Float_t fMaxEta;
+  Float_t fMinPhi;
+  Float_t fMaxPhi;
+  Int_t   fNEtaDiv;
+  Int_t   fNPhiDiv;
+
+  Float_t fEtaScale;
+  Float_t fPhiScale;
+  Float_t fEnergyScale;
+  Float_t fEnergyColorScale;
+
+  Color_t fGridColor;
+
+  Reve::ZTrans  fHMTrans;
+
+  std::vector<AliAODJet>   fJets;
+  std::vector<AliAODTrack> fTracks;
+
+  Bool_t                 fRnrJets;
+  Bool_t                 fRnrTracks;
+  Bool_t                 fOneSelection;
+  Bool_t                 fTwoSelection;
+
+  AliAODJet             *fJet1,   *fJet2;
+  AliAODTrack           *fTrack1, *fTrack2;
+
+  Int_t                  fSelectionFlag;
+
+  static Bool_t fgOneMomentumXYZ;
+  static Bool_t fgOneMomentumPhiTheta;
+  static Bool_t fgOneEta;
+  static Bool_t fgOneE;
+  static Bool_t fgOneChgMass;
+
+public:
+  JetPlane(Int_t iev);
+  virtual ~JetPlane() {}
+
+  void AddJet(AliAODJet jet);
+  void AddTrack(AliAODTrack track);
+
+  Int_t GetNEtaDiv() const   { return fNEtaDiv; }
+  void  SetNEtaDiv(Int_t r) { fNEtaDiv = r; }
+
+  Int_t GetNPhiDiv() const   { return fNPhiDiv; }
+  void  SetNPhiDiv(Int_t r) { fNPhiDiv = r; }
+
+  Bool_t GetRnrJets() const   { return fRnrJets; }
+  void   SetRnrJets(Bool_t r) { fRnrJets = r; }
+
+  Bool_t GetRnrTracks() const   { return fRnrTracks; }
+  void   SetRnrTracks(Bool_t r) { fRnrTracks = r; }
+
+  Bool_t GetOneSelection() const   { return fOneSelection; }
+  void   SetOneSelection(Bool_t r) { fOneSelection = r; }
+
+  Bool_t GetTwoSelection() const   { return fTwoSelection; }
+  void   SetTwoSelection(Bool_t r) { fTwoSelection = r; }
+
+  Float_t GetEnergyScale() const { return fEnergyScale; }
+  void    SetEnergyScale(Float_t s) { fEnergyScale = s; }
+
+  Float_t GetEnergyColorScale() const { return fEnergyColorScale; }
+  void    SetEnergyColorScale(Float_t s) { fEnergyColorScale = s; }
+
+  const AliAODJet& GetJet1() const { return *fJet1; }
+  const AliAODJet& GetJet2() const { return *fJet2; }
+  const AliAODTrack& GetTrack1() const { return *fTrack1; }
+  const AliAODTrack& GetTrack2() const { return *fTrack2; }
+
+  void    SetJet1(AliAODJet* s) { fJet1 = s; }
+  void    SetJet2(AliAODJet* s) { fJet2 = s; }
+  void    SetTrack1(AliAODTrack* s) { fTrack1 = s; }
+  void    SetTrack2(AliAODTrack* s) { fTrack2 = s; }
+
+  void    SetSelectionFlag(Int_t s) { fSelectionFlag = s;}
+
+  virtual Bool_t  CanEditMainColor()   { return kTRUE; }
+
+  virtual Bool_t  CanEditMainHMTrans() { return kTRUE; }
+  virtual Reve::ZTrans* PtrMainHMTrans()     { return &fHMTrans; }
+
+  virtual void ComputeBBox();
+  virtual void Paint(Option_t* option = "");
+
+  Reve::ZTrans& RefHMTrans() { return fHMTrans; }
+  void SetTransMatrix(Double_t* carr)        { fHMTrans.SetFrom(carr); }
+  void SetTransMatrix(const TGeoMatrix& mat) { fHMTrans.SetFrom(mat);  }
+
+  ClassDef(JetPlane, 1);
+}; // endclass JetPlane
+
+}
+
+#endif
diff --git a/EVE/Alieve/JetPlaneEditor.cxx b/EVE/Alieve/JetPlaneEditor.cxx
new file mode 100644 (file)
index 0000000..a3f0c25
--- /dev/null
@@ -0,0 +1,286 @@
+// $Header$
+
+#include "JetPlaneEditor.h"
+#include <Alieve/JetPlane.h>
+#include <Reve/RGValuators.h>
+
+#include <TVirtualPad.h>
+#include <TColor.h>
+#include <TROOT.h>
+#include <TGLabel.h>
+#include <TGButton.h>
+#include <TGNumberEntry.h>
+#include <TGColorSelect.h>
+#include <TGDoubleSlider.h>
+#include <TGFrame.h>
+#include <TGTab.h>
+
+using namespace Reve;
+using namespace Alieve;
+
+//______________________________________________________________________
+// JetPlaneEditor
+//
+
+Alieve::JetPlaneEditor::StaticDataWindow* JetPlaneEditor::fgStaticWindow = 0;
+
+ClassImp(JetPlaneEditor)
+
+JetPlaneEditor::JetPlaneEditor(const TGWindow *p, Int_t width, Int_t height,
+                              UInt_t options, Pixel_t back) :
+  TGedFrame(p, width, height, options | kVerticalFrame, back),
+  fM(0),
+  fRnrJets(0),
+  fRnrTracks(0),
+  fEnergyScale(0),
+  fEnergyColorScale(0),
+  fOneSelection(0),
+  fTwoSelection(0),
+  fInformationSetup(0)
+  // Initialize widget pointers to 0
+{
+  MakeTitle("JetPlane");
+  Int_t labelW = 67;
+
+  // Create widgets
+  // fXYZZ = new TGSomeWidget(this, ...);
+  // AddFrame(fXYZZ, new TGLayoutHints(...));
+  // fXYZZ->Connect("SignalName()", "Alieve::JetPlaneEditor", this, "DoXYZZ()");
+
+  fRnrJets  = new TGCheckButton(this, "Rnr Jets");
+  AddFrame(fRnrJets, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+  fRnrJets->Connect("Clicked()", "Alieve::JetPlaneEditor", this, "DoRnrJets()");
+
+  fRnrTracks  = new TGCheckButton(this, "Rnr Tracks");
+  AddFrame(fRnrTracks, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+  fRnrTracks->Connect("Clicked()", "Alieve::JetPlaneEditor", this, "DoRnrTracks()");
+
+  fEnergyScale = new RGValuator(this, "Length scale:", 110, 0);
+  fEnergyScale->SetLabelWidth(labelW);
+  fEnergyScale->SetNELength(6);
+  fEnergyScale->Build();
+  fEnergyScale->SetLimits(1, 500, 500, TGNumberFormat::kNESRealOne);
+  fEnergyScale->SetToolTip("Energy mapped to length of arrow.");
+  fEnergyScale->Connect("ValueSet(Double_t)", "Alieve::JetPlaneEditor", this, "DoEnergyScale()");
+  AddFrame(fEnergyScale, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+
+  fEnergyColorScale = new RGValuator(this, "Color scale:", 110, 0);
+  fEnergyColorScale->SetLabelWidth(labelW);
+  fEnergyColorScale->SetNELength(6);
+  fEnergyColorScale->Build();
+  fEnergyColorScale->SetLimits(-2, 2, 100, TGNumberFormat::kNESRealOne);
+  fEnergyColorScale->SetToolTip("Energy mapped to highest palette color.");
+  fEnergyColorScale->Connect("ValueSet(Double_t)", "Alieve::JetPlaneEditor", this, "DoEnergyColorScale()");
+  AddFrame(fEnergyColorScale, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+
+  fOneSelection = new TGRadioButton(this, "&One Track/Jet");
+  fTwoSelection = new TGRadioButton(this, "&Two Track/Jet");
+  AddFrame(fOneSelection, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+  AddFrame(fTwoSelection, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+  fOneSelection->Connect("Clicked()", "Alieve::JetPlaneEditor", this, "DoOneSelection()");
+  fTwoSelection->Connect("Clicked()", "Alieve::JetPlaneEditor", this, "DoTwoSelection()");
+
+  // fInformationSetup = new TGTextButton(this, "Track/Jet Print");
+  // AddFrame(fInformationSetup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 0, 2, 2));
+  // fInformationSetup->Connect("Clicked()", "Alieve::JetPlaneEditor", this, "DoStaticDataWindow()");
+}
+
+JetPlaneEditor::~JetPlaneEditor()
+{}
+
+/**************************************************************************/
+
+void JetPlaneEditor::SetModel(TObject* obj)
+{
+  fM = dynamic_cast<JetPlane*>(obj);
+
+  // Set values of widgets
+  // fXYZZ->SetValue(fM->GetXYZZ());
+  fRnrJets->SetState(fM->GetRnrJets() ? kButtonDown : kButtonUp);
+  fRnrTracks->SetState(fM->GetRnrTracks() ? kButtonDown : kButtonUp);
+  fEnergyScale->SetValue(fM->GetEnergyScale());
+  fEnergyColorScale->SetValue(fM->GetEnergyColorScale());
+  fOneSelection->SetState(fM->GetOneSelection() ? kButtonDown : kButtonUp);
+  fTwoSelection->SetState(fM->GetTwoSelection() ? kButtonDown : kButtonUp);
+}
+
+/**************************************************************************/
+
+// Implements callback/slot methods
+
+// void JetPlaneEditor::DoXYZZ()
+// {
+//   fM->SetXYZZ(fXYZZ->GetValue());
+//   Update();
+// }
+
+void JetPlaneEditor::DoRnrJets()
+{
+  fM->SetRnrJets(fRnrJets->IsOn());
+  Update();
+}
+
+void JetPlaneEditor::DoRnrTracks()
+{
+  fM->SetRnrTracks(fRnrTracks->IsOn());
+  Update();
+}
+
+void JetPlaneEditor::DoEnergyColorScale()
+{
+  fM->SetEnergyColorScale(fEnergyColorScale->GetValue());
+  Update();
+}
+
+void JetPlaneEditor::DoEnergyScale()
+{
+  fM->SetEnergyScale(fEnergyScale->GetValue());
+  Update();
+}
+
+void JetPlaneEditor::DoOneSelection()
+{
+  fTwoSelection->SetState(kButtonUp);
+  fM->SetOneSelection(fOneSelection->IsOn());
+  fM->SetTwoSelection(fTwoSelection->IsOn());
+  Update();
+}
+
+void JetPlaneEditor::DoTwoSelection()
+{
+  fOneSelection->SetState(kButtonUp);
+  fM->SetOneSelection(fOneSelection->IsOn());
+  fM->SetTwoSelection(fTwoSelection->IsOn());
+  Update();
+}
+
+void JetPlaneEditor::DoStaticDataWindow()
+{      
+  printf("\n Soon available ... \n");
+  if (fgStaticWindow == 0)
+    fgStaticWindow = new StaticDataWindow(gClient->GetRoot(), this, 400, 200);
+
+  // call fgStaticWindow->ReadValues(); // like setmodel
+
+  // position relative to the parent's window
+  fgStaticWindow->MapWindow();
+  fgStaticWindow->RaiseWindow();
+  fgStaticWindow->CenterOnParent();
+}
+
+/**************************************************************************/
+
+ClassImp(JetPlaneEditor::StaticDataWindow)
+
+JetPlaneEditor::StaticDataWindow::StaticDataWindow(const TGWindow *p, const TGWindow *main,
+                                                  UInt_t w, UInt_t h, UInt_t options) :
+  TGTransientFrame(p, main, w, h, options),
+  fFrame1(0),
+  fOkButton(0),
+  fCancelButton(0),
+  fL1(0),
+  fL2(0),
+  fL3(0),
+  fL5(0),
+  fTab(0),
+  fChk1(0),fChk2(0),fChk3(0),fChk4(0),fChk5(0)
+{
+  // Create a dialog window. A dialog window pops up with respect to its
+  // "main" window.
+
+  Connect("CloseWindow()", "JetPlaneEditor::StaticDataWindow", this, "DoClose()");
+  DontCallClose(); // to avoid double deletions.
+
+  // use hierarchical cleaning
+  SetCleanup(kDeepCleanup);
+
+  fFrame1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
+
+  fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
+  fOkButton->Connect("Clicked()", "JetPlaneEditor::StaticDataWindow", this, "DoOK()");
+  fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
+  fCancelButton->Connect("Clicked()", "JetPlaneEditor::StaticDataWindow", this, "DoCancel()");
+
+  fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2, 2, 2, 2);
+  fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
+
+  fFrame1->AddFrame(fOkButton, fL1);
+  fFrame1->AddFrame(fCancelButton, fL1);
+
+  fFrame1->Resize(150, fOkButton->GetDefaultHeight());
+  AddFrame(fFrame1, fL2);
+
+  // Tabs for one and two track information
+
+  fTab = new TGTab(this, 300, 300);
+  fTab->Connect("Selected(Int_t)", "JetPlaneEditor::StaticDataWindow", this, "DoTab(Int_t)");
+
+  fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
+
+  TGCompositeFrame *tf = fTab->AddTab("One Track/Jet");
+
+  //    fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
+  //    fF1->AddFrame(new TGTextButton(fF1, "&Test button", 0), fL3);
+  //    fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
+  //    fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
+  //    tf->AddFrame(fF1, fL3);
+  //    fTxt1->Resize(150, fTxt1->GetDefaultHeight());
+  //    fTxt2->Resize(150, fTxt2->GetDefaultHeight());
+  fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
+  fF2 = new TGCompositeFrame(tf, 60, 60, kVerticalFrame);
+  fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "4-Momentum: {pt, px, py, pz} "), fL1);
+  fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "4-Momentum: {pt, Phi, Theta}"), fL1);
+  fF2->AddFrame(fChk3 = new TGCheckButton(fF2, "Pseudorapidity: Eta"), fL1);
+  fF2->AddFrame(fChk4 = new TGCheckButton(fF2, "Energy: E"), fL1);
+  fF2->AddFrame(fChk5 = new TGCheckButton(fF2, "Charge and Mass"), fL1);
+
+  tf = fTab->AddTab("Two Tracks/Jets");
+
+  tf->AddFrame(fF2, fL3);
+
+  //    fBtn1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+  //    fBtn2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+  //    fChk1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+  //    fChk2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+  //    fRad1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+  //    fRad2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
+
+
+  TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
+                                        kLHintsExpandY, 2, 2, 5, 1);
+  AddFrame(fTab, fL5);
+
+  MapSubwindows();
+  Resize();
+
+  SetWindowName("Track/Jet Common Setup");
+}
+
+JetPlaneEditor::StaticDataWindow::~StaticDataWindow()
+{
+  DeleteWindow();
+}
+
+void JetPlaneEditor::StaticDataWindow::DoClose()
+{
+  UnmapWindow();
+}
+
+void JetPlaneEditor::StaticDataWindow::DoOK()
+{
+  // Read data from widgets, copy to static members of JetPlane
+
+  SendCloseMessage();
+}
+
+void JetPlaneEditor::StaticDataWindow::DoCancel()
+{
+  SendCloseMessage();
+}
+
+void JetPlaneEditor::StaticDataWindow::DoTab(Int_t /*id*/)
+{
+  // printf("Tab item %d activated\n", id);
+}
+
+
diff --git a/EVE/Alieve/JetPlaneEditor.h b/EVE/Alieve/JetPlaneEditor.h
new file mode 100644 (file)
index 0000000..018a35c
--- /dev/null
@@ -0,0 +1,94 @@
+// $Header$
+
+#ifndef ALIEVE_JetPlaneEditor_H
+#define ALIEVE_JetPlaneEditor_H
+
+#include <TGedFrame.h>
+#include <RQ_OBJECT.h>
+
+class TGButton;
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+
+namespace Reve
+{
+  class RGValuator;
+}
+
+namespace Alieve {
+
+// class RGValuator;
+
+class JetPlane;
+
+class JetPlaneEditor : public TGedFrame
+{
+private:
+  JetPlaneEditor(const JetPlaneEditor&);            // Not implemented
+  JetPlaneEditor& operator=(const JetPlaneEditor&); // Not implemented
+
+protected:
+  JetPlane          *fM; // fModel dynamic-casted to JetPlaneEditor
+
+  // Declare widgets
+  // TGSomeWidget*   fXYZZ;
+  TGCheckButton*     fRnrJets;
+  TGCheckButton*     fRnrTracks;
+  Reve::RGValuator*  fEnergyScale;
+  Reve::RGValuator*  fEnergyColorScale;
+  TGButton          *fOneSelection, *fTwoSelection;
+  TGButton          *fInformationSetup;
+
+public:
+  JetPlaneEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30,
+                UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+  virtual ~JetPlaneEditor();
+
+  virtual void SetModel(TObject* obj);
+
+  // Declare callback/slot methods
+  // void DoXYZZ();
+  void DoRnrJets();
+  void DoRnrTracks();
+  void DoEnergyColorScale();
+  void DoEnergyScale();
+  void DoOneSelection();
+  void DoTwoSelection();
+  void DoStaticDataWindow();
+
+
+  // --- Internal class for common settings
+public:
+  class StaticDataWindow : public TGTransientFrame
+  {
+  private:
+    TGCompositeFrame    *fFrame1, *fF2;
+    TGButton            *fOkButton, *fCancelButton;
+    TGLayoutHints       *fL1, *fL2, *fL3, *fL5;
+    TGTab               *fTab;
+    TGButton            *fChk1, *fChk2,*fChk3, *fChk4,*fChk5;
+
+  public:
+    StaticDataWindow(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h,
+                    UInt_t options = kVerticalFrame);
+    virtual ~StaticDataWindow();
+
+    // slots
+    void DoClose();
+    void DoOK();
+    void DoCancel();
+    void DoTab(Int_t id);
+
+    ClassDef(StaticDataWindow, 0);
+  };
+
+protected:
+  static StaticDataWindow* fgStaticWindow;
+
+  ClassDef(JetPlaneEditor, 1); // Editor for JetPlane
+}; // endclass JetPlaneEditor
+
+}
+
+#endif
diff --git a/EVE/Alieve/JetPlaneGL.cxx b/EVE/Alieve/JetPlaneGL.cxx
new file mode 100644 (file)
index 0000000..bf9703f
--- /dev/null
@@ -0,0 +1,342 @@
+// $Header$
+
+#include "JetPlaneGL.h"
+#include <Alieve/JetPlane.h>
+#include <Reve/GLUtilNS.h>
+
+#include <TGLRnrCtx.h>
+#include <TGLSelectRecord.h>
+#include <TGLIncludes.h>
+
+#include "TGLUtil.h"
+#include "TGLAxis.h"
+
+#include <TColor.h>
+#include <TStyle.h>
+#include <TROOT.h>
+
+using namespace Reve;
+using namespace Alieve;
+
+//______________________________________________________________________
+// JetPlaneGL
+//
+
+ClassImp(JetPlaneGL)
+
+JetPlaneGL::JetPlaneGL() : TGLObject(), fM(0)
+{
+  fDLCache = kFALSE; // Disable display list -- axis pain.
+}
+
+JetPlaneGL::~JetPlaneGL()
+{}
+
+/**************************************************************************/
+
+Bool_t JetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/)
+{
+  if(SetModelCheckClass(obj, Alieve::JetPlane::Class())) {
+    fM = dynamic_cast<JetPlane*>(obj);
+    return kTRUE;
+  }
+  return kFALSE;
+}
+
+void JetPlaneGL::SetBBox()
+{
+  // !! This ok if master sub-classed from TAttBBox
+  SetAxisAlignedBBox(((JetPlane*)fExternalObj)->AssertBBox());
+}
+
+/**************************************************************************/
+
+void JetPlaneGL::DirectDraw(TGLRnrCtx & /*rnrCtx*/) const
+{
+
+  Float_t minEta = (fM->fMinEta)*(fM->fEtaScale);
+  Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale);
+  Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale);
+  Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale);
+  Float_t phiCoord, etaCoord, dPhi, dEta;
+  Double_t eta, phi, E, x, y;
+
+  // Show frame for Eta-Phi coordinates
+
+  glBegin(GL_LINE_LOOP);
+  glVertex3f( minEta, minPhi, 0);
+  glVertex3f( maxEta, minPhi, 0);
+  glVertex3f( maxEta, maxPhi, 0);
+  glVertex3f( minEta, maxPhi, 0);
+  glEnd();
+
+  // Show grid in Eta-Phi coordinates
+
+  dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1);
+  dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1);
+
+  for (int count=1; count < fM->fNPhiDiv-1; count++)
+  {
+    phiCoord = minPhi + count*dPhi;
+    glBegin(GL_LINES);
+    glVertex3f( minEta, phiCoord, 0);
+    glVertex3f( maxEta, phiCoord, 0);
+    glEnd();
+  }
+
+  for (int count=1; count < fM->fNEtaDiv-1; count++)
+  {
+    etaCoord = minEta + count*dEta;
+    glBegin(GL_LINES);
+    glVertex3f( etaCoord, minPhi, 0);
+    glVertex3f( etaCoord, maxPhi, 0);
+    glEnd();
+  }
+
+  // Show axis tick marks and labels
+
+  {
+    GLUtilNS::GL_Capability_Switch lights_off(GL_LIGHTING, false);
+
+    TGLAxis ap;
+    ap.SetLineColor(fM->fGridColor);
+    ap.SetTextColor(fM->fGridColor);
+    TGLVector3 start, end;
+
+    start.Set(minEta, minPhi, 0);
+    end.Set(maxEta, minPhi, 0);
+    ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205);
+
+    start.Set(maxEta, minPhi, 0);
+    end.Set(maxEta, maxPhi, 0);
+    ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205);
+
+  }
+
+  // Finding the maximum energy
+
+  std::vector<AliAODTrack>::iterator k = fM->fTracks.begin();
+  std::vector<AliAODJet>::iterator   j = fM->fJets.begin();
+
+  Double_t eJetMax = 0., eTrackMax = 0., eMax;
+
+  while (j != fM->fJets.end())
+  {
+    if (j->E() > eJetMax) eJetMax = j->E();
+    ++j;
+  }
+
+  while (k != fM->fTracks.end())
+  {
+    if (k->E() > eTrackMax) eTrackMax = k->E();
+    ++k;
+  }
+
+  eMax = eJetMax > eTrackMax ? eJetMax : eTrackMax;
+
+  // Rendering Jets and Tracks in the Eta-Phi plane
+
+  Int_t     nCol = gStyle->GetNumberOfColors();
+  Float_t col[4] = { 0., 0., 0., 0.75};
+
+  glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+  TGLUtil::SetDrawQuality(6);
+
+
+  glPushName(0);
+  if (fM->fRnrJets)
+  {
+    glEnable(GL_BLEND);                   // Turn Blending On
+    glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off
+    UInt_t jetid = 0;
+
+
+    j = fM->fJets.begin();
+
+    while (j != fM->fJets.end())
+    {
+      eta = j->Eta();
+      phi = j->Phi();
+      E   = j->E();
+
+      x = eta*(fM->fEtaScale);
+      y = phi*(fM->fPhiScale);
+
+      Int_t colBin = TMath::Min((Int_t) ((nCol-2)*E*
+                                        TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
+      Int_t colIdx = gStyle->GetColorPalette(colBin);
+      TColor* c    = gROOT->GetColor(colIdx);
+
+      if(c)
+      {
+       col[0] = c->GetRed();
+       col[1] = c->GetGreen();
+       col[2] = c->GetBlue();
+      }
+
+      glLoadName(jetid);
+      TGLUtil::DrawLine( TGLVertex3(x,y,0.),
+                        TGLVector3(0.,0.,TMath::Log(E + 1.)*fM->fEnergyScale),
+                        TGLUtil::kLineHeadArrow, 25.0, col);
+
+      ++j; ++jetid;
+    }
+  }
+
+  col[3] = 1.0;
+
+  glPushName(1);
+  if(fM->fRnrTracks)
+  {
+    glDisable(GL_BLEND);                  // Turn Blending Off
+    glEnable(GL_DEPTH_TEST);    // Turn Depth Testing On
+    UInt_t trackid = 0;
+
+
+    k = fM->fTracks.begin();
+
+    while (k != fM->fTracks.end())
+    {
+      eta = k->Eta();
+      phi = k->Phi();
+      E   = k->E();
+
+      if (E < 0.)
+      {
+       //                      printf(" WARNING: Particle with negative energy has been found.\n");
+       //                      printf(" PARTICLE NOT DISPLAYED. TrackID: %i\n", trackid);
+       ++k; ++trackid;
+       continue;
+      }
+
+      x = eta*(fM->fEtaScale);
+      y = phi*(fM->fPhiScale);
+
+      Int_t colBin = TMath::Min((Int_t) ((nCol-2)*E*
+                                        TMath::Power(10.,fM->fEnergyColorScale)/(eMax)),nCol-2);
+      Int_t colIdx = gStyle->GetColorPalette(colBin);
+      TColor* c    = gROOT->GetColor(colIdx);
+
+      if(c)
+      {
+       col[0] = c->GetRed();
+       col[1] = c->GetGreen();
+       col[2] = c->GetBlue();
+      }
+
+      glLoadName(trackid);
+      TGLUtil::DrawLine( TGLVertex3(x,y,0.),
+                        TGLVector3(0.,0.,TMath::Log(E + 1.)*fM->fEnergyScale),
+                        TGLUtil::kLineHeadArrow, 5.0, col);
+
+      ++k; ++trackid;
+    }
+  }
+
+  glPopName();
+  TGLUtil::ResetDrawQuality();
+
+
+
+}
+
+/**************************************************************************/
+
+void JetPlaneGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
+{
+  //   printf("beep %u\n", rec.GetN());
+  //   rec.Print();
+  static Int_t jet1State;
+  static Int_t jet2State;
+  static Int_t track1State;
+  static Int_t track2State;
+
+  if (fM->fOneSelection)
+  {
+    printf("\n");
+
+    if (rec.GetN() == 2)
+    {
+      AliAODJet v = fM->fJets[rec.GetItem(1)];
+      printf("Jet 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
+      printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
+    }
+
+    if (rec.GetN() == 3)
+    {
+      AliAODTrack v = fM->fTracks[rec.GetItem(2)];
+      printf("Track 4-momentum: %f, %f, %f, %f \n", v.Px(),v.Py(),v.Pz(),v.Pt() );
+      printf("Eta-Phi values: %f, %f\n", v.Eta(), v.Phi());
+    }
+  }
+
+  if (fM->fTwoSelection)
+  {
+
+    if ( fM->fSelectionFlag == 1)
+    {
+      if (rec.GetN() == 2)
+      {
+       fM->SetJet1(&(fM->fJets[rec.GetItem(1)]));
+        jet1State = 1;
+       track1State = 0;
+      }
+
+      if (rec.GetN() == 3)
+      {
+       fM->SetTrack1(&(fM->fTracks[rec.GetItem(1)]));
+       jet1State = 0;
+       track1State = 1;
+      }
+
+      fM->SetSelectionFlag(2);
+
+      return;
+    }
+
+    if ( fM->fSelectionFlag == 2)
+    {
+      printf("\n");
+      if (rec.GetN() == 2)
+      {
+       fM->SetJet2(&(fM->fJets[rec.GetItem(1)]));
+        jet2State = 1;
+       track2State = 0;
+      }
+
+      if (rec.GetN() == 3)
+      {
+       fM->SetTrack2(&(fM->fTracks[rec.GetItem(1)]));
+       jet2State = 0;
+       track2State = 1;
+      }
+
+      printf("Jet: %i, Track: %i \n", jet1State, track1State);
+      printf("Jet: %i, Track: %i \n\n", jet2State, track2State);
+
+      if(jet1State && jet2State)
+      {
+       Double_t Eta1, Eta2, Phi1, Phi2, d;
+
+       Eta1 = (fM->GetJet1()).Eta();
+       Eta2 = (fM->GetJet2()).Eta();
+       Phi1 = (fM->GetJet1()).Phi();
+        Phi2 = (fM->GetJet2()).Phi();
+
+       d = TMath::Sqrt(TMath::Power(Eta2-Eta1,2) + TMath::Power(Phi2-Phi1,2));
+
+       printf("Eta-Phi: %f, %f\n", Eta1, Phi1 );
+       printf("Eta-Phi: %f, %f\n", Eta2, Phi2 );
+       printf("Eta-Phi Distance: %f\n", d);
+      }
+
+      fM->SetSelectionFlag(1);
+    }
+
+  }
+
+}
+
+
+
+
diff --git a/EVE/Alieve/JetPlaneGL.h b/EVE/Alieve/JetPlaneGL.h
new file mode 100644 (file)
index 0000000..2ba3a81
--- /dev/null
@@ -0,0 +1,42 @@
+// $Header$
+
+#ifndef ALIEVE_JetPlaneGL_H
+#define ALIEVE_JetPlaneGL_H
+
+#include <TGLObject.h>
+
+class TGLViewer;
+class TGLScene;
+
+namespace Alieve {
+
+class JetPlane;
+
+class JetPlaneGL : public TGLObject
+{
+private:
+  JetPlaneGL(const JetPlaneGL&);            // Not implemented
+  JetPlaneGL& operator=(const JetPlaneGL&); // Not implemented
+
+protected:
+  JetPlane* fM; // fModel dynamic-casted to JetPlaneGL
+
+  virtual void DirectDraw(TGLRnrCtx & rnrCtx) const;
+
+public:
+  JetPlaneGL();
+  virtual ~JetPlaneGL();
+
+  virtual Bool_t SetModel(TObject* obj, const Option_t* opt=0);
+  virtual void   SetBBox();
+
+  // To support two-level selection
+  virtual Bool_t SupportsSecondarySelect() const { return kTRUE; }
+  virtual void ProcessSelection(TGLRnrCtx & rnrCtx, TGLSelectRecord & rec);
+
+  ClassDef(JetPlaneGL, 0);
+}; // endclass JetPlaneGL
+
+}
+
+#endif