From Stefano:
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 May 2010 13:47:12 +0000 (13:47 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 May 2010 13:47:12 +0000 (13:47 +0000)
- New classes for eta-phi calorimeter-like display of track transverse
momentum.
- Add ability to select events on beam A/C/both.

EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/EveBase/AliEveLego.cxx [new file with mode: 0644]
EVE/EveBase/AliEveLego.h [new file with mode: 0644]
EVE/EveBase/AliEveLegoEditor.cxx [new file with mode: 0644]
EVE/EveBase/AliEveLegoEditor.h [new file with mode: 0644]
EVE/EveBase/EveBaseLinkDef.h
EVE/alice-macros/lego.C [new file with mode: 0644]
EVE/macros/visscan_init.C

index d7e2453..d23761d 100644 (file)
@@ -10,6 +10,7 @@
 #include "AliEveEventManager.h"
 #include "AliEveEventSelector.h"
 #include "AliEveMacroExecutor.h"
+#include <TEveElement.h>
 #include <TEveManager.h>
 #include <TEveViewer.h>
 
@@ -43,6 +44,8 @@
 #include <TPRegexp.h>
 #include <TError.h>
 #include <TEnv.h>
+#include <TString.h>
+#include <TMap.h>
 
 //==============================================================================
 //==============================================================================
@@ -129,6 +132,8 @@ void AliEveEventManager::InitInternals()
   gEve->AddToListTree(fTransientLists, kFALSE);
 
   fPEventSelector = new AliEveEventSelector(this);
+
+  fGlobal = new TMap; fGlobal->SetOwnerKeyValue();
 }
 
 AliEveEventManager::AliEveEventManager(const TString& name) :
@@ -142,6 +147,7 @@ AliEveEventManager::AliEveEventManager(const TString& name) :
   fRawReader (0),
   fAutoLoad  (kFALSE), fAutoLoadTime (5.),     fAutoLoadTimer(0),
   fIsOpen    (kFALSE), fHasEvent     (kFALSE), fExternalCtrl (kFALSE),
+  fGlobal    (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
   fExecutor    (0), fTransients(0), fTransientLists(0),
   fPEventSelector(0),
   fSubManagers (0),
@@ -163,6 +169,7 @@ AliEveEventManager::AliEveEventManager(const TString& name, const TString& path,
   fRawReader (0),
   fAutoLoad  (kFALSE), fAutoLoadTime (5),      fAutoLoadTimer(0),
   fIsOpen    (kFALSE), fHasEvent     (kFALSE), fExternalCtrl (kFALSE),
+  fGlobal    (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
   fExecutor    (0), fTransients(0), fTransientLists(0),
   fPEventSelector(0),
   fSubManagers (0),
@@ -1525,3 +1532,59 @@ Bool_t AliEveEventManager::InitGRP()
 
   return kTRUE;
 } 
+
+//------------------------------------
+// Global variables management
+//------------------------------------
+
+Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model)
+{
+   // Insert a new visualization-parameter database entry with the default
+   return InsertGlobal(tag, model, fGlobalReplace, fGlobalUpdate);
+}
+
+Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model,
+                    Bool_t replace, Bool_t update)
+{
+   TPair* pair = (TPair*) fGlobal->FindObject(tag);
+   if (pair)
+   {
+      if (replace)
+      {
+         model->IncDenyDestroy();
+         model->SetRnrChildren(kFALSE);
+
+         TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value());
+         while (old_model->HasChildren())
+         {
+            TEveElement *el = old_model->FirstChild();
+            el->SetVizModel(model);
+            if (update)
+            {
+               el->CopyVizParams(model);
+               el->PropagateVizParamsToProjecteds();
+            }
+         }
+         old_model->DecDenyDestroy();
+
+         pair->SetValue(dynamic_cast<TObject*>(model));
+         return kTRUE;
+      }
+      else
+      {
+         return kFALSE;
+      }
+   }
+   else
+   {
+      model->IncDenyDestroy();
+      model->SetRnrChildren(kFALSE);
+      fGlobal->Add(new TObjString(tag), dynamic_cast<TObject*>(model));
+      return kTRUE;
+   }
+}
+
+TEveElement* AliEveEventManager::FindGlobal(const TString& tag)
+{
+   return dynamic_cast<TEveElement*>(fGlobal->GetValue(tag));
+}
index e248e5c..3eb9ca2 100644 (file)
@@ -15,7 +15,7 @@
 #include <TObjArray.h>
 
 class AliEveMacroExecutor;
-class AliEveEventSelector;
+class AliEveEventSelector; 
 
 class AliRunLoader;
 class AliESDEvent;
@@ -26,9 +26,12 @@ class AliRawReader;
 class AliGRPObject;
 class AliMagF;
 
+class TEveElement;
 class TFile;
 class TTree;
 class TGeoManager;
+class TString;
+class TMap;
 
 //==============================================================================
 //
@@ -116,6 +119,11 @@ public:
   Bool_t        AreEventFilesOpened()    const { return fIsOpen;       }
   Bool_t        IsEventAvailable()       const { return fHasEvent;     }
   Bool_t        IsUnderExternalControl() const { return fExternalCtrl; }
+  
+  Bool_t        InsertGlobal(const TString& tag, TEveElement* model);
+  Bool_t        InsertGlobal(const TString& tag, TEveElement* model,
+                             Bool_t replace, Bool_t update);
+  TEveElement*  FindGlobal(const TString& tag);
 
   virtual void  AfterNewEventLoaded();
   void          NewEventDataLoaded();  // *SIGNAL*
@@ -148,6 +156,10 @@ protected:
   Bool_t        fHasEvent;              // Is an event available.
   Bool_t        fExternalCtrl;          // Are we under external event-loop.
 
+  TMap*         fGlobal;
+  Bool_t        fGlobalReplace;         // Are global replace
+  Bool_t        fGlobalUpdate;          // Are global updates
+
   AliEveMacroExecutor *fExecutor;       // Executor for std macros
 
   TEveElementList     *fTransients;     // Container for additional transient (per event) elements.
diff --git a/EVE/EveBase/AliEveLego.cxx b/EVE/EveBase/AliEveLego.cxx
new file mode 100644 (file)
index 0000000..647925d
--- /dev/null
@@ -0,0 +1,768 @@
+// $Id$
+// Author: Stefano Carrazza 2010
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#include "AliESDEvent.h"
+#include "AliEveLego.h"
+#include "AliEveEventManager.h"
+#include "AliEveMultiView.h"
+#include "AliPhysicsSelection.h"
+#include "AliEveEventSelector.h"
+
+#include "TH2F.h"
+#include "TMath.h"
+#include "TGLViewer.h"
+#include "TEveWindow.h"
+#include "TEveManager.h"
+#include "TEveBrowser.h"
+#include "TEveViewer.h"
+#include "TEveScene.h"
+#include "TEveCaloLegoOverlay.h"
+#include "TEveCalo.h"
+#include "TEveCaloData.h"
+#include "TEveLegoEventHandler.h"
+#include "TEveTrans.h"
+#include "TEveProjectionManager.h"
+#include "TEveProjectionAxes.h"
+#include "TGLWidget.h"
+#include "TGLOverlayButton.h"
+
+//______________________________________________________________________________
+// Allow histograms visualization in 2D and 3D.
+//
+
+ClassImp(AliEveLego)
+Double_t pi = TMath::Pi();
+
+//______________________________________________________________________________
+AliEveLego::AliEveLego(const char* name) :
+  TEveElementList(name),
+  fChargeId(1),
+  fTracksId(1),
+  fEventsId(1),
+  fMaxPt(10000),
+  fChargeIdAE(0),
+  fTracksIdAE(0),
+  fMaxPtAE(0),
+  fEsd(0),
+  fPhysicsSelection(0),
+  fHistopos(0),
+  fHistoposclone(0),
+  fHistopos_all_events(0),
+  fHistoneg(0),
+  fHistonegclone(0),
+  fHistoneg_all_events(0),
+  fData(0),
+  fData_all_events(0),
+  fLego(0),
+  fLego_all_events(0),
+  fCalo3d(0),
+  fCalo3d_all_events(0),
+  fGlv(0),
+  fHisto2d_v(0),
+  fHisto2d_s(0),
+  fHisto2d_s2(0),
+  fHisto2d_all_events_v0(0),
+  fHisto2d_all_events_v1(0),
+  fHisto2d_all_events_v2(0),
+  fHisto2d_all_events_v3(0),
+  fHisto2d_all_events_s0(0),
+  fHisto2d_all_events_s1(0),
+  fHisto2d_all_events_s2(0),
+  fHisto2d_all_events_s3(0),
+  fAl(0),
+  fHisto2d_lego_overlay(0),
+  fHisto2d_all_events_lego_overlay(0),
+  fHisto2d_all_events_slot(0),
+  fEventSelector(0),
+  fShowEventsInfo(0),
+  fGButton(0),
+  fB1(0),
+  fB2(0)
+{
+  // Constructor.
+  gEve->AddToListTree(this,0);
+
+  // Get Current ESD event
+  fEsd = AliEveEventManager::AssertESD();
+
+  fPhysicsSelection = new AliPhysicsSelection();
+  fPhysicsSelection->Initialize(fEsd->GetRunNumber());
+
+  fEventSelector = AliEveEventManager::GetMaster()->GetEventSelector();
+
+  fHistopos = new TH2F("histopos","Histo 2d positive", 100, -1.5, 1.5, 80, -pi, pi);
+  fHistoneg = new TH2F("histoneg","Histo 2d negative", 100, -1.5, 1.5, 80, -pi, pi);
+//  fHistoposclone = new TH2F("histoposclone","Histo 2d positive", 100, -1.5, 1.5, 80, -pi, pi);
+//  fHistonegclone = new TH2F("histonegclone","Histo 2d positive", 100, -1.5, 1.5, 80, -pi, pi);
+
+  fData = new TEveCaloDataHist();
+  fData->AddHistogram(fHistoneg);
+  fData->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
+  fData->AddHistogram(fHistopos);
+  fData->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
+  fData->GetEtaBins()->SetTitleFont(120);
+  fData->GetEtaBins()->SetTitle("h");
+  fData->GetPhiBins()->SetTitleFont(120);
+  fData->GetPhiBins()->SetTitle("f");
+  fData->IncDenyDestroy();
+
+  fCalo3d = new TEveCalo3D(fData);
+  fCalo3d->SetBarrelRadius(550);
+  fCalo3d->SetEndCapPos(550);
+
+  // plotting histo
+  fLego = new TEveCaloLego(fData);
+
+  // projections
+  fAl = AliEveMultiView::Instance();
+  fAl->ImportEventRPhi(fCalo3d);
+  fAl->ImportEventRhoZ(fCalo3d);
+
+  // glbutton
+  fGButton = new TGLOverlayButton(0, "", 10.0, -10.0, 190.0, 20.0);
+  fGButton->SetAlphaValues(1.5,1.5);
+  fB1 = new TGLOverlayButton(0, "", 10.0, -30.0, 190.0, 20.0);
+  fB1->SetAlphaValues(1.5,1.5);
+  fB2 = new TGLOverlayButton(0, "", 10.0, -50.0, 190.0, 20.0);
+  fB2->SetAlphaValues(1.5,1.5);
+
+  // Update
+  Update();
+}
+
+//______________________________________________________________________________
+AliEveLego::~AliEveLego()
+{
+   delete fEsd;
+   delete fPhysicsSelection;
+   delete fHistopos;
+   delete fHistopos_all_events;
+   delete fHistoneg;
+   delete fHistoneg_all_events;
+
+   delete fData;
+   delete fData_all_events;
+   delete fLego;
+   delete fLego_all_events;
+   delete fCalo3d;
+   delete fCalo3d_all_events;
+   delete fGlv;
+
+   delete fHisto2d_v;
+   delete fHisto2d_s;
+   delete fHisto2d_s2;
+   delete fHisto2d_all_events_v0;
+   delete fHisto2d_all_events_v1;
+   delete fHisto2d_all_events_v2;
+   delete fHisto2d_all_events_v3;
+   delete fHisto2d_all_events_s0;
+   delete fHisto2d_all_events_s1;
+   delete fHisto2d_all_events_s2;
+   delete fHisto2d_all_events_s3;
+
+   delete fAl;
+   delete fHisto2d_lego_overlay;
+   delete fHisto2d_all_events_lego_overlay;
+   delete fHisto2d_all_events_slot;
+
+   delete fEventSelector;
+   delete fGButton;
+   delete fB1;
+   delete fB2;
+}
+
+//______________________________________________________________________________
+Double_t getphi(Double_t phi)
+{
+   Double_t pi = TMath::Pi();
+
+   if (phi > pi) {
+      phi -= 2*pi;
+   }
+   return phi;
+}
+
+//______________________________________________________________________________
+TEveCaloDataHist* AliEveLego::LoadData()
+{
+
+   fHistopos->Reset();
+   fHistoneg->Reset();
+
+   // Getting current tracks, filling histograms
+   for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
+
+      if (fEsd->GetTrack(n)->GetSign() > 0) {
+         fHistopos->Fill(fEsd->GetTrack(n)->Eta(),
+                         getphi(fEsd->GetTrack(n)->Phi()),
+                         fabs(fEsd->GetTrack(n)->Pt()));
+      }
+
+      if (fEsd->GetTrack(n)->GetSign() < 0) {
+         fHistoneg->Fill(fEsd->GetTrack(n)->Eta(),
+                         getphi(fEsd->GetTrack(n)->Phi()),
+                         fabs(fEsd->GetTrack(n)->Pt()));
+      }
+   }
+
+//   fHistoposclone = (TH2F*)fHistopos->Clone("histoposclone");
+//   fHistonegclone = (TH2F*)fHistoneg->Clone("histonegclone");
+//   fHistoposclone->SetName("histoposclone");
+//   fHistonegclone->SetName("histonegclone");
+
+   fData->DataChanged();
+
+   FilterData();
+
+   return fData;
+}
+
+//______________________________________________________________________________
+TEveCaloDataHist* AliEveLego::LoadAllData()
+{
+
+   fHistopos_all_events->Reset();
+   fHistoneg_all_events->Reset();
+
+   TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
+
+   // Getting current tracks for each event, filling histograms
+   for (int event = 0; event < t->GetEntries(); event++) {
+      t->GetEntry(event);
+         for (int n = 0; n < fEsd->GetNumberOfTracks(); ++n) {
+
+            if (fEsd->GetTrack(n)->GetSign() > 0) {
+               fHistopos_all_events->Fill(fEsd->GetTrack(n)->Eta(),
+                                          getphi(fEsd->GetTrack(n)->Phi()),
+                                          fabs(fEsd->GetTrack(n)->Pt()));
+            } else {
+               fHistoneg_all_events->Fill(fEsd->GetTrack(n)->Eta(),
+                                          getphi(fEsd->GetTrack(n)->Phi()),
+                                          fabs(fEsd->GetTrack(n)->Pt()));
+            }
+         }
+   }
+
+   fData_all_events->DataChanged();
+
+   return fData_all_events;
+}
+
+//______________________________________________________________________________
+TEveCaloDataHist* AliEveLego::FilterData()
+{
+   // Tracks selection
+   if ( fTracksId == 2 )
+   {
+      fHistopos->Reset();
+      fHistoneg->Reset();
+
+      const AliESDVertex *pv  = fEsd->GetPrimaryVertex();
+
+      for (Int_t n = 0; n < pv->GetNIndices(); n++ )
+      {
+         AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
+         if (at->GetSign() > 0) {
+            fHistopos->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
+         }
+         if (at->GetSign() < 0) {
+            fHistoneg->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
+         }
+      }
+   }
+
+   fData->DataChanged();
+
+   // Max Pt threshold
+   if (GetPtMax() >= fMaxPt){
+      for (Int_t binx = 1; binx <= 100; binx++) {
+         for (Int_t biny = 1; biny <= 80; biny++) {
+            if (fHistopos->GetBinContent(binx, biny) >= fMaxPt)
+            {
+               fHistopos->SetBinContent(binx, biny, fMaxPt);
+            }
+            if (fHistoneg->GetBinContent(binx, biny) >= fMaxPt)
+            {
+               fHistoneg->SetBinContent(binx, biny, fMaxPt);
+            }           
+         }
+      }
+   }
+
+   // Positive only
+   if ( fChargeId == 2 ) fHistoneg->Reset();
+
+   // Negative only
+   if ( fChargeId == 3 ) fHistopos->Reset();
+
+   fData->DataChanged();
+
+   return fData;
+}
+
+
+//______________________________________________________________________________
+TEveCaloDataHist* AliEveLego::FilterAllData()
+{
+   // Tracks selection
+   if ( fTracksIdAE == 2 )
+   {
+      fHistopos_all_events->Reset();
+      fHistoneg_all_events->Reset();
+
+      TTree* t = AliEveEventManager::GetMaster()->GetESDTree();
+
+      // Getting current tracks for each event, filling histograms
+      for (int event = 0; event < t->GetEntries(); event++) {
+         t->GetEntry(event);
+
+      const AliESDVertex *pv  = fEsd->GetPrimaryVertex();
+
+      for (Int_t n = 0; n < pv->GetNIndices(); n++ )
+      {
+         AliESDtrack *at = fEsd->GetTrack(pv->GetIndices()[n]);
+         if (at->GetSign() > 0) {
+            fHistopos_all_events->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
+         }
+         if (at->GetSign() < 0) {
+            fHistoneg_all_events->Fill(at->Eta(), getphi(at->Phi()), fabs(at->Pt()));
+         }
+      }
+   }
+   } else {
+      LoadAllData();
+   }
+   
+   fData_all_events->DataChanged();
+   
+   // Max Pt threshold
+   if (GetPtMaxAE() >= fMaxPtAE){
+      for (Int_t binx = 1; binx <= 100; binx++) {
+         for (Int_t biny = 1; biny <= 80; biny++) {
+            if (fHistopos_all_events->GetBinContent(binx, biny) >= fMaxPtAE)
+            {
+               fHistopos_all_events->SetBinContent(binx, biny, fMaxPtAE);
+            }
+            if (fHistoneg_all_events->GetBinContent(binx, biny) >= fMaxPtAE)
+            {
+               fHistoneg_all_events->SetBinContent(binx, biny, fMaxPtAE);
+            }           
+         }
+      }
+   }
+
+   // Positive only
+   if ( fChargeIdAE == 2 ) fHistoneg_all_events->Reset();
+
+   // Negative only
+   if ( fChargeIdAE == 3 ) fHistopos_all_events->Reset();
+
+   fData_all_events->DataChanged();
+
+   gEve->Redraw3D(kTRUE);
+
+   return fData_all_events;
+}
+
+//______________________________________________________________________________
+void AliEveLego::Update()
+{
+   // Load/Reload data
+   LoadData();
+
+   // Create new histo2d
+   CreateHistoLego();
+
+   // Create 3d view
+   Create3DView();
+
+   // Show information about event;
+   ShowEventSeletion(fShowEventsInfo, kTRUE);
+
+   // Update the viewers
+   gEve->Redraw3D(kTRUE);
+}
+
+//______________________________________________________________________________
+TEveCaloLego* AliEveLego::CreateHistoLego()
+{
+   // Viewer initialization, tab creation
+   if (fHisto2d_v == 0) {
+      TEveWindowSlot *fslot    = 0;
+      TEveBrowser    *fbrowser = gEve->GetBrowser();
+
+      fslot = TEveWindow::CreateWindowInTab(fbrowser->GetTabRight());
+      fslot->MakeCurrent();
+      fHisto2d_v = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
+      fHisto2d_s = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
+      fHisto2d_v->AddScene(fHisto2d_s);
+      fHisto2d_v->SetElementName("2D Lego Viewer");
+      fHisto2d_s->SetElementName("2D Lego Scene");
+
+      fGlv = fHisto2d_v->GetGLViewer();
+      fHisto2d_lego_overlay = new TEveCaloLegoOverlay();
+      fGlv->AddOverlayElement(fHisto2d_lego_overlay);
+      fGlv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
+
+      fHisto2d_s->AddElement(fLego);
+
+      // move to real world coordinates
+      fLego->InitMainTrans();
+      Float_t sc = TMath::Min(fLego->GetEtaRng(), fLego->GetPhiRng());
+      fLego->RefMainTrans().SetScale(sc, sc, sc);
+
+      // set event handler to move from perspective to orthographic view.
+      fGlv->SetEventHandler(new TEveLegoEventHandler(fGlv->GetGLWidget(), fGlv, fLego));
+
+      fHisto2d_lego_overlay->SetCaloLego(fLego);
+   }
+
+   return fLego;
+}
+
+//______________________________________________________________________________
+TEveCaloLego* AliEveLego::CreateHistoLego(TEveWindowSlot *slot)
+{
+   // Viewer initialization, tab creation
+   if (fHisto2d_all_events_v0 == 0) {
+
+      slot->MakeCurrent();
+      fHisto2d_all_events_v0 = gEve->SpawnNewViewer("2D Lego Histogram", "2D Lego Histogram");
+      fHisto2d_all_events_s0 = gEve->SpawnNewScene("2D Lego Histogram", "2D Lego Histogram");
+      fHisto2d_all_events_v0->AddScene(fHisto2d_all_events_s0);
+      fHisto2d_all_events_v0->SetElementName("2D Lego Viewer");
+      fHisto2d_all_events_s0->SetElementName("2D Lego Scene");
+
+      TGLViewer* glv = fHisto2d_all_events_v0->GetGLViewer();
+      fHisto2d_all_events_lego_overlay = new TEveCaloLegoOverlay();
+      glv->AddOverlayElement(fHisto2d_all_events_lego_overlay);
+      glv->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
+
+      // Plotting histogram lego
+      fLego_all_events = new TEveCaloLego(fData_all_events);
+      fHisto2d_all_events_s0->AddElement(fLego_all_events);
+
+      // Move to real world coordinates
+      fLego_all_events->InitMainTrans();
+      Float_t sc = TMath::Min(fLego_all_events->GetEtaRng(), fLego_all_events->GetPhiRng());
+      fLego_all_events->RefMainTrans().SetScale(sc, sc, sc);
+
+      // Set event handler to move from perspective to orthographic view.
+      glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, fLego_all_events));
+
+      fHisto2d_all_events_lego_overlay->SetCaloLego(fLego_all_events);
+   }
+
+   return fLego_all_events;
+}
+
+//______________________________________________________________________________
+TEveCalo3D* AliEveLego::Create3DView()
+{
+   //initialization
+   if (fHisto2d_s2 == 0) {
+      fHisto2d_s2 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
+      gEve->GetDefaultViewer()->AddScene(fHisto2d_s2);
+      fHisto2d_s2->SetElementName("3D Histogram Scene");
+      fHisto2d_s2->AddElement(fCalo3d);
+   }
+
+   return fCalo3d;
+}
+
+//______________________________________________________________________________
+TEveCalo3D* AliEveLego::Create3DView(TEveWindowSlot *slot)
+{
+   if ( fHisto2d_all_events_v1 == 0 ) {
+
+      slot->MakeCurrent();
+      fHisto2d_all_events_v1 = gEve->SpawnNewViewer("3D Histogram", "3D Histogram");
+      fHisto2d_all_events_s1 = gEve->SpawnNewScene("3D Histogram", "3D Histogram");
+      fHisto2d_all_events_v1->AddScene(fHisto2d_all_events_s1);
+      fHisto2d_all_events_v1->SetElementName("3D Histogram Viewer");
+      fHisto2d_all_events_s1->SetElementName("3D Histogram Scene");
+
+      fCalo3d_all_events = new TEveCalo3D(fData_all_events);
+
+      fCalo3d_all_events->SetBarrelRadius(550);
+      fCalo3d_all_events->SetEndCapPos(550);
+      fHisto2d_all_events_s1->AddElement(fCalo3d_all_events);
+   }
+
+   return fCalo3d_all_events;
+}
+
+//______________________________________________________________________________
+void AliEveLego::CreateProjections(TEveWindowSlot* slot1, TEveWindowSlot* slot2){
+
+   if (fHisto2d_all_events_v2 == 0) {
+
+      slot1->MakeCurrent();
+      fHisto2d_all_events_v2 = gEve->SpawnNewViewer("RPhi projection", "RPhi projection");
+      fHisto2d_all_events_s2 = gEve->SpawnNewScene("RPhi projection", "RPhi projection");
+      fHisto2d_all_events_v2->AddScene(fHisto2d_all_events_s2);
+      fHisto2d_all_events_v2->SetElementName("RPhi Projection Viewer");
+      fHisto2d_all_events_s2->SetElementName("RPhi Projection Scene");
+
+      TEveProjectionManager* mng1 = new TEveProjectionManager();
+      mng1->SetProjection(TEveProjection::kPT_RPhi);
+
+      TEveProjectionAxes* axeg_histo2d_all_events_s1 = new TEveProjectionAxes(mng1);
+      fHisto2d_all_events_s2->AddElement(axeg_histo2d_all_events_s1);
+      TEveCalo2D* fcalo2d1 = (TEveCalo2D*) mng1->ImportElements(fCalo3d_all_events);
+      fHisto2d_all_events_s2->AddElement(fcalo2d1);
+
+      fHisto2d_all_events_v2->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+   }
+
+   if (fHisto2d_all_events_v3 == 0) {
+
+      slot2->MakeCurrent();
+      fHisto2d_all_events_v3 = gEve->SpawnNewViewer("RhoZ projection", "RhoZ projection");
+      fHisto2d_all_events_s3 = gEve->SpawnNewScene("RhoZ projection", "RhoZ projection");
+      fHisto2d_all_events_v3->AddScene(fHisto2d_all_events_s3);
+      fHisto2d_all_events_v3->SetElementName("RhoZ Projection Viewer");
+      fHisto2d_all_events_s3->SetElementName("RhoZ Projection Viewer");
+
+      TEveProjectionManager* mng2 = new TEveProjectionManager();
+      mng2->SetProjection(TEveProjection::kPT_RhoZ);
+
+      TEveProjectionAxes* axeg_histo2d_all_events_s2 = new TEveProjectionAxes(mng2);
+      fHisto2d_all_events_s3->AddElement(axeg_histo2d_all_events_s2);
+      TEveCalo2D* fcalo2d2 = (TEveCalo2D*) mng2->ImportElements(fCalo3d_all_events);
+      fHisto2d_all_events_s3->AddElement(fcalo2d2);
+
+      fHisto2d_all_events_v3->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+   }
+
+   return;
+}
+
+//______________________________________________________________________________
+TEveCaloDataHist* AliEveLego::LoadAllEvents()
+{
+   if ( fHisto2d_all_events_slot == 0 ) {
+
+      printf("Filling histogram...\n");
+
+      // Creating 2D histograms
+      fHistopos_all_events = new TH2F("fHistopos_all_events","Histo 2d positive",
+                                 100,-1.5,1.5,80,-pi,pi);
+      fHistoneg_all_events = new TH2F("fHistoneg_all_events","Histo 2d negative",
+                                 100,-1.5,1.5,80,-pi,pi);
+
+      fData_all_events = new TEveCaloDataHist();
+      fData_all_events->AddHistogram(fHistoneg_all_events);
+      fData_all_events->RefSliceInfo(0).Setup("NegCg:", 0, kBlue);
+      fData_all_events->AddHistogram(fHistopos_all_events);
+      fData_all_events->RefSliceInfo(1).Setup("PosCg:", 0, kRed);
+      fData_all_events->GetEtaBins()->SetTitleFont(120);
+      fData_all_events->GetEtaBins()->SetTitle("h");
+      fData_all_events->GetPhiBins()->SetTitleFont(120);
+      fData_all_events->GetPhiBins()->SetTitle("f");
+      fData_all_events->IncDenyDestroy();
+
+      // Creating frames
+      fHisto2d_all_events_slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+      TEveWindowPack* packH = fHisto2d_all_events_slot->MakePack();
+      packH->SetElementName("Projections");
+      packH->SetHorizontal();
+      packH->SetShowTitleBar(kFALSE);
+
+      fHisto2d_all_events_slot = packH->NewSlot();
+      TEveWindowPack* pack0 = fHisto2d_all_events_slot->MakePack();
+      pack0->SetShowTitleBar(kFALSE);
+      TEveWindowSlot*  slotLeftTop   = pack0->NewSlot();
+      TEveWindowSlot* slotLeftBottom = pack0->NewSlot();
+
+      fHisto2d_all_events_slot = packH->NewSlot();
+      TEveWindowPack* pack1 = fHisto2d_all_events_slot->MakePack();
+      pack1->SetShowTitleBar(kFALSE);
+      TEveWindowSlot* slotRightTop    = pack1->NewSlot();
+      TEveWindowSlot* slotRightBottom = pack1->NewSlot();
+
+      // Creating viewers and scenes
+      Create3DView(slotLeftTop);
+      CreateHistoLego(slotLeftBottom);
+      CreateProjections(slotRightTop, slotRightBottom);
+
+      LoadAllData();
+
+      gEve->Redraw3D(kTRUE);
+
+      printf("Filling histogram... Finished\n");
+   }
+
+   return fData_all_events;
+}
+
+//______________________________________________________________________________
+Float_t AliEveLego::GetPtMax()
+{
+   return fData->GetMaxVal(fLego->GetPlotEt());
+}
+
+//______________________________________________________________________________
+Float_t AliEveLego::GetPtMaxAE()
+{
+   return fData_all_events->GetMaxVal(fLego_all_events->GetPlotEt());
+}
+
+//______________________________________________________________________________
+void AliEveLego::SetMaxPt(Double_t val)
+{
+   // Add new maximum
+   fMaxPt = val;   
+   Update();
+}
+
+//______________________________________________________________________________
+void AliEveLego::SetMaxPtAE(Double_t val)
+{
+   // Add new maximum
+   fMaxPtAE = val;
+   FilterAllData();
+}
+
+//______________________________________________________________________________
+void AliEveLego::SetThreshold(Double_t val)
+{  
+   // Setting up the new threshold for all histograms
+   fData->SetSliceThreshold(0,val);
+   fData->SetSliceThreshold(1,val);
+   fData->DataChanged();
+
+   gEve->Redraw3D(kTRUE);
+}
+
+//______________________________________________________________________________
+void AliEveLego::SetThresholdAE(Double_t val)
+{
+   // Setting up the new threshold for all histograms
+   fData_all_events->SetSliceThreshold(0,val);
+   fData_all_events->SetSliceThreshold(1,val);
+   fData_all_events->DataChanged();
+
+   gEve->Redraw3D(kTRUE);
+}
+
+//______________________________________________________________________________
+void AliEveLego::SetEventSelection()
+{
+   if (fShowEventsInfo == 0)
+   {
+      fShowEventsInfo = 1;
+   } else {
+      fShowEventsInfo = 0;
+   }
+
+   ShowEventSeletion(fShowEventsInfo);
+}
+
+//______________________________________________________________________________
+void AliEveLego::ShowEventSeletion(Bool_t show, Bool_t updateonly)
+{
+   if (show == 0)
+   {
+      gEve->GetDefaultGLViewer()->RemoveOverlayElement(fGButton);
+      fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fGButton);
+      fHisto2d_v->GetGLViewer()->RemoveOverlayElement(fGButton);
+
+      gEve->GetDefaultGLViewer()->RemoveOverlayElement(fB1);
+      fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fB1);
+      fHisto2d_v->GetGLViewer()->RemoveOverlayElement(fB1);
+
+      gEve->GetDefaultGLViewer()->RemoveOverlayElement(fB2);
+      fAl->Get3DView()->GetGLViewer()->RemoveOverlayElement(fB2);
+      fHisto2d_v->GetGLViewer()->RemoveOverlayElement(fB2);
+
+   } else {
+
+      //Collision candidate
+      if (updateonly == kFALSE) {
+         gEve->GetDefaultGLViewer()->AddOverlayElement(fGButton);
+         fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fGButton);
+         fHisto2d_v->GetGLViewer()->AddOverlayElement(fGButton);
+      }
+
+      Bool_t ev = fPhysicsSelection->IsCollisionCandidate(fEsd);
+
+      if (ev == 1)
+      {
+         fGButton->SetText("Collision candidate: YES");
+      } else {
+         fGButton->SetText("Collision candidate: NO ");
+      }
+
+      // Beam 1 & 2 setup: method 1
+      if (updateonly == kFALSE) {
+         gEve->GetDefaultGLViewer()->AddOverlayElement(fB1);
+         fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fB1);
+         fHisto2d_v->GetGLViewer()->AddOverlayElement(fB1);
+
+         gEve->GetDefaultGLViewer()->AddOverlayElement(fB2);
+         fAl->Get3DView()->GetGLViewer()->AddOverlayElement(fB2);
+         fHisto2d_v->GetGLViewer()->AddOverlayElement(fB2);
+      }
+
+      Bool_t b1  = fEsd->IsTriggerClassFired("CINT1A-ABCE-NOPF-ALL");
+      Bool_t b2  = fEsd->IsTriggerClassFired("CINT1C-ABCE-NOPF-ALL");
+      Bool_t b12 = fEsd->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL");
+
+      if (b1 == 1 || b12 == 1)
+      {
+         fB1->SetText("Beam 1: YES");
+         fB1->SetBackColor(0x00ff00);
+      } else {
+         fB1->SetText("Beam 1: NO");
+         fB1->SetBackColor(0xff0000);
+      }
+
+      if (b2 == 1 || b12 == 1)
+      {
+         fB2->SetText("Beam 2: YES");
+         fB2->SetBackColor(0x00ff00);
+      } else {
+         fB2->SetText("Beam 2: NO");
+         fB2->SetBackColor(0xff0000);
+      }
+   }
+
+   gEve->Redraw3D(kTRUE);
+
+}
+
+//______________________________________________________________________________
+void AliEveLego::SelectEventSelection(Int_t id)
+{
+   if (id == 0)
+   {
+      fEventSelector->SetSelectOnTriggerType(kFALSE);
+   } else {
+      if (id == 1) fEventSelector->SetTriggerType("CINT1A-ABCE-NOPF-ALL");
+      if (id == 2) fEventSelector->SetTriggerType("CINT1C-ABCE-NOPF-ALL");
+      if (id == 3) fEventSelector->SetTriggerType("CINT1B-ABCE-NOPF-ALL");
+      fEventSelector->SetSelectOnTriggerType(kTRUE);
+   }
+}
+
+//______________________________________________________________________________
+void AliEveLego::ShowPrevEvent()
+{
+   AliEveEventManager::GetMaster()->PrevEvent();
+}
+
+//______________________________________________________________________________
+void AliEveLego::ShowNextEvent()
+{
+   AliEveEventManager::GetMaster()->NextEvent();
+}
+/******************************************************************************/
+
+
diff --git a/EVE/EveBase/AliEveLego.h b/EVE/EveBase/AliEveLego.h
new file mode 100644 (file)
index 0000000..5af425f
--- /dev/null
@@ -0,0 +1,141 @@
+// $Id$
+// Author: Stefano Carrazza 2010
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#ifndef AliEveLego_H
+#define AliEveLego_H
+
+#include "TEveElement.h"
+
+class AliESDEvent;
+class AliEveEventSelector;
+class AliEveMultiView;
+class AliPhysicsSelection;
+
+class TEveCaloDataHist;
+class TEveCaloLego;
+class TEveCaloLegoOverlay;
+class TEveCalo3D;
+class TEveScene;
+class TEveViewer;
+class TEveWindowSlot;
+class TGLOverlayButton;
+class TGLViewer;
+class TH2F;
+
+//______________________________________________________________________________
+// Creates a 2D lego histogram on a new tab.
+// Allow 3D visualization and projection of the lego histogram on the 3D Viewer and the MultiView.
+//
+
+class AliEveLego : public TEveElementList
+{
+public:
+  AliEveLego(const char* name="AliEveLego");
+  virtual ~AliEveLego();
+
+  // Get Methods
+  TEveCaloDataHist* GetData()           {   return fData;             }
+  TEveCaloDataHist* GetDataAllEvents()  {   return fData_all_events;  }
+  AliESDEvent*      GetESD()            {   return fEsd;              }
+  TEveCaloLego*     GetLego()           {   return fLego;             }
+  TEveCaloLego*     GetLegoAllEvents()  {   return fLego_all_events;  }
+  TEveCalo3D*       GetCalo3D()         {   return fCalo3d;           }
+  TEveCalo3D*       GetCalo3DAllEvents(){   return fCalo3d_all_events;}
+  AliEveMultiView*  GetMultiView()      {   return fAl;               }
+  Float_t           GetPtMax();
+  Float_t           GetPtMaxAE();
+
+  // Set Methods
+  void SetCharge(Int_t id) {  fChargeId = id;  Update();  }
+  void SetAllEventsCharge(Int_t id) {  fChargeIdAE = id; FilterAllData();  }
+  void SetTracks(Int_t id) {  fTracksId = id;  Update();  }
+  void SetTracksAE(Int_t id) {  fTracksIdAE = id;  FilterAllData();  }
+  void SetEvents(Int_t id) {  fEventsId = id;  Update();  }
+  void SetMaxPt(Double_t val);
+  void SetMaxPtAE(Double_t val);
+  void SetThreshold(Double_t val);
+  void SetThresholdAE(Double_t val);
+  void SetEventSelection();
+  void ShowPrevEvent();
+  void ShowNextEvent();
+
+  // Functions
+  void Update();
+  TEveCaloDataHist* LoadData();
+  TEveCaloDataHist* LoadAllData();
+  TEveCaloDataHist* FilterData();
+  TEveCaloDataHist* FilterAllData();
+  TEveCaloLego*     CreateHistoLego();
+  TEveCaloLego*     CreateHistoLego(TEveWindowSlot* slot);
+  TEveCalo3D*       Create3DView();
+  TEveCalo3D*       Create3DView(TEveWindowSlot* slot);
+  void              CreateProjections(TEveWindowSlot* slot1,
+                                      TEveWindowSlot* slot2);
+  TEveCaloDataHist* LoadAllEvents();
+  void              ShowEventSeletion(Bool_t show, Bool_t updateonly = kFALSE);
+  void              SelectEventSelection(Int_t id);
+
+private:
+  Int_t fChargeId;
+  Int_t fTracksId;
+  Int_t fEventsId;
+  Float_t fMaxPt;
+
+  Int_t fChargeIdAE;
+  Int_t fTracksIdAE;
+  Float_t fMaxPtAE;
+
+  AliESDEvent *fEsd;
+  AliPhysicsSelection *fPhysicsSelection;
+  TH2F *fHistopos;
+  TH2F *fHistoposclone;
+  TH2F *fHistopos_all_events;
+  TH2F *fHistoneg;
+  TH2F *fHistonegclone;
+  TH2F *fHistoneg_all_events;
+
+  TEveCaloDataHist *fData;
+  TEveCaloDataHist *fData_all_events;
+  TEveCaloLego *fLego;
+  TEveCaloLego *fLego_all_events;
+  TEveCalo3D *fCalo3d;
+  TEveCalo3D *fCalo3d_all_events;
+  TGLViewer  *fGlv;
+
+  TEveViewer *fHisto2d_v;
+  TEveScene  *fHisto2d_s;
+  TEveScene  *fHisto2d_s2;
+  TEveViewer *fHisto2d_all_events_v0;
+  TEveViewer *fHisto2d_all_events_v1;
+  TEveViewer *fHisto2d_all_events_v2;
+  TEveViewer *fHisto2d_all_events_v3;
+  TEveScene  *fHisto2d_all_events_s0;
+  TEveScene  *fHisto2d_all_events_s1;
+  TEveScene  *fHisto2d_all_events_s2;
+  TEveScene  *fHisto2d_all_events_s3;
+
+  AliEveMultiView *fAl;
+  TEveCaloLegoOverlay *fHisto2d_lego_overlay;
+  TEveCaloLegoOverlay* fHisto2d_all_events_lego_overlay;
+  TEveWindowSlot* fHisto2d_all_events_slot;
+
+  AliEveEventSelector *fEventSelector;
+  Bool_t fShowEventsInfo;
+  TGLOverlayButton *fGButton;
+  TGLOverlayButton *fB1;
+  TGLOverlayButton *fB2;
+
+  AliEveLego(const AliEveLego&);            // Not implemented
+  AliEveLego& operator=(const AliEveLego&); // Not implemented
+
+
+  ClassDef(AliEveLego, 0); // Short description.
+};
+
+#endif
diff --git a/EVE/EveBase/AliEveLegoEditor.cxx b/EVE/EveBase/AliEveLegoEditor.cxx
new file mode 100644 (file)
index 0000000..b0de7c2
--- /dev/null
@@ -0,0 +1,329 @@
+// $Id$
+// Author: Stefano Carrazza 2010
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#include "AliEveLegoEditor.h"
+#include "AliEveLego.h"
+
+#include "TVirtualPad.h"
+#include "TColor.h"
+
+#include "TGLabel.h"
+#include "TGButton.h"
+#include "TGNumberEntry.h"
+#include "TGColorSelect.h"
+#include "TGDoubleSlider.h"
+#include "TGButtonGroup.h"
+#include "TGString.h"
+#include "TGComboBox.h"
+#include "TGFrame.h"
+
+//______________________________________________________________________________
+// GUI editor for AliEveLego.
+//
+
+ClassImp(AliEveLegoEditor)
+
+//______________________________________________________________________________
+AliEveLegoEditor::AliEveLegoEditor(const TGWindow *p, Int_t width, Int_t height,
+             UInt_t options, Pixel_t back) :
+  TGedFrame(p, width, height, options | kVerticalFrame, back),
+  fM(0),
+
+  fAllEventsButton(0),
+  fParticlesBG(0),
+  fTrackSelection(0),
+  fEventSelection(0),
+  fRevents(0),
+  fLabel(0),
+  fLabel1(0),
+  fThreshold(0),
+  fMaxPt(0),
+  fSelect(0),
+  fButtonPrev(0),
+  fButtonNext(0),
+
+  fParticlesBGAE(0),
+  fTrackSelectionAE(0),
+  fEventSelectionAE(0),
+  fReventsAE(0),
+  fLabelAE(0),
+  fLabel1AE(0),
+  fThresholdAE(0),
+  fMaxPtAE(0),
+  fSelectAE(0),
+  fButtonPrevAE(0),
+  fButtonNextAE(0)
+{
+  // Constructor.
+  MakeTitle("AliEveLego");
+
+  // Create widgets
+  fAllEventsButton = new TGTextButton(this, "Create lego of all events");
+  AddFrame(fAllEventsButton, new TGLayoutHints(kLHintsExpandX));
+  fAllEventsButton->Connect("Clicked()", "AliEveLegoEditor", this, "DoAllEvents()");
+
+  fParticlesBG = new TGButtonGroup(this, "Charge selection:", kVerticalFrame);
+  fRcharge[0] = new TGRadioButton(fParticlesBG, new TGHotString("&Positive and negative"));
+  fRcharge[1] = new TGRadioButton(fParticlesBG, new TGHotString("&Only positive"));
+  fRcharge[2] = new TGRadioButton(fParticlesBG, new TGHotString("&Only negative"));
+  fRcharge[0]->SetState(kButtonDown);
+  AddFrame(fParticlesBG, new TGLayoutHints(kLHintsExpandX));
+  fParticlesBG->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByCharge(Int_t)");
+
+  fTrackSelection = new TGButtonGroup(this, "Track selection:", kHorizontalFrame);
+  fRtracks[0] = new TGRadioButton(fTrackSelection, new TGHotString("&All tracks  "));
+  fRtracks[1] = new TGRadioButton(fTrackSelection, new TGHotString("&Primary tracks"));
+  fRtracks[0]->SetState(kButtonDown);
+  AddFrame(fTrackSelection, new TGLayoutHints(kLHintsExpandX));
+  fTrackSelection->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracks(Int_t)");
+
+  //**************
+
+  TGHorizontalFrame *horz = new TGHorizontalFrame(this);
+  AddFrame(horz, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
+  fLabel = new TGLabel(horz, "Tracks maximum Pt (GeV): ");
+  horz->AddFrame(fLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
+
+  fMaxPt = new TGNumberEntry(horz, 10000, 7, -1,
+                                 TGNumberFormat::kNESRealOne,
+                                 TGNumberFormat::kNEANonNegative,
+                                 TGNumberFormat::kNELLimitMinMax,
+                                 0, 10000);
+
+  fMaxPt->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPt()");
+
+  horz->AddFrame( fMaxPt, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
+
+  TGHorizontalFrame *horz1 = new TGHorizontalFrame(this);
+  AddFrame(horz1, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
+  fLabel1 = new TGLabel(horz1, "Tracks threshold (GeV): ");
+  horz1->AddFrame(fLabel1, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
+
+  fThreshold = new TGNumberEntry(horz1, 0, 7, -1,
+                                 TGNumberFormat::kNESRealOne,
+                                 TGNumberFormat::kNEANonNegative,
+                                 TGNumberFormat::kNELLimitMinMax,
+                                 0, 10000);
+
+  fThreshold->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThreshold()");
+  horz1->AddFrame( fThreshold, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
+
+
+
+  //***************
+
+  // Events selection
+  fEventSelection = new TGGroupFrame(this, "Event selection:", kHorizontalFrame);
+
+  fRevents = new TGCheckButton(fEventSelection, new TGHotString("&Show info "));
+  fRevents->SetState(kButtonUp);
+  fRevents->Connect("Clicked()", "AliEveLegoEditor", this, "ShowEventSelection()");
+  fEventSelection->AddFrame(fRevents, new TGLayoutHints(kLHintsLeft | kLHintsTop));
+
+  fSelect = new TGComboBox(fEventSelection,-1,kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
+  fSelect->AddEntry("All events",0);
+  fSelect->AddEntry("Beam 1",1);
+  fSelect->AddEntry("Beam 2",2);
+  fSelect->AddEntry("Beams 1 & 2",3);
+  fSelect->Resize(102,22);
+  fSelect->Select(0);
+  fEventSelection->AddFrame(fSelect, new TGLayoutHints(kLHintsRight | kLHintsExpandX));
+
+  fSelect->Connect("Selected(Int_t)", "AliEveLegoEditor", this, "SelectEventSelection(Int_t)");
+
+  AddFrame(fEventSelection, new TGLayoutHints(kLHintsExpandX));
+
+  //**********
+
+  TGHorizontalFrame *horz3 = new TGHorizontalFrame(this);
+
+  fButtonPrev = new TGTextButton(horz3, "Previous event");
+  horz3->AddFrame(fButtonPrev, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));
+  fButtonPrev->Connect("Clicked()", "AliEveLegoEditor", this, "ShowPrevEvent()");
+
+  fButtonNext = new TGTextButton(horz3, "Next event");
+  horz3->AddFrame( fButtonNext, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsExpandX));
+  fButtonNext->Connect("Clicked()", "AliEveLegoEditor", this, "ShowNextEvent()");
+
+  AddFrame(horz3, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
+
+  //**********
+
+
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SetModel(TObject* obj)
+{
+  fM = dynamic_cast<AliEveLego*>(obj);
+}
+
+/******************************************************************************/
+
+// Implements callback/slot methods
+
+//______________________________________________________________________________
+// void AliEveLegoEditor::DoXYZZ()
+// {
+//    // Slot for XYZZ.
+//
+//    fM->SetXYZZ(fXYZZ->GetValue());
+//    Update();
+// }
+
+//______________________________________________________________________________
+void AliEveLegoEditor::DoAllEvents()
+{
+  // Slot for XYZZ.
+  fAllEventsButton->SetEnabled(kFALSE);
+  CreateAllEventsEditor();
+  fM->LoadAllEvents();
+
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowByCharge(Int_t id)
+{   
+  fM->SetCharge(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowByChargeAE(Int_t id)
+{
+   fM->SetAllEventsCharge(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SetMaxPt()
+{
+   fM->SetMaxPt(fMaxPt->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SetMaxPtAE()
+{
+   fM->SetMaxPtAE(fMaxPtAE->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SetThreshold()
+{
+   fM->SetThreshold(fThreshold->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SetThresholdAE()
+{
+   fM->SetThresholdAE(fThresholdAE->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowByTracks(Int_t id)
+{
+   fM->SetTracks(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowByTracksAE(Int_t id)
+{
+   fM->SetTracksAE(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowByEvents(Int_t id)
+{
+   fM->SetEvents(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowEventSelection()
+{
+   fM->SetEventSelection();
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::SelectEventSelection(Int_t id)
+{
+   fM->SelectEventSelection(id);
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::CreateAllEventsEditor()
+{
+   TGVerticalFrame *this2 = this->CreateEditorTabSubFrame("All events style");
+
+   TGLabel *ftitle = new TGLabel(this2, "AliLego all events ------");
+   this2->AddFrame(ftitle, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
+
+   fParticlesBGAE = new TGButtonGroup(this2, "Charge selection:", kVerticalFrame);
+   fRchargeAE[0] = new TGRadioButton(fParticlesBGAE, new TGHotString("&Positive and negative"));
+   fRchargeAE[1] = new TGRadioButton(fParticlesBGAE, new TGHotString("&Only positive"));
+   fRchargeAE[2] = new TGRadioButton(fParticlesBGAE, new TGHotString("&Only negative"));
+   fRchargeAE[0]->SetState(kButtonDown);
+   this2->AddFrame(fParticlesBGAE, new TGLayoutHints(kLHintsExpandX));
+
+   fParticlesBGAE->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByChargeAE(Int_t)");
+
+   fTrackSelectionAE = new TGButtonGroup(this2, "Track selection:", kHorizontalFrame);
+   fRtracksAE[0] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&All tracks  "));
+   fRtracksAE[1] = new TGRadioButton(fTrackSelectionAE, new TGHotString("&Primary tracks"));
+   fRtracksAE[0]->SetState(kButtonDown);
+   this2->AddFrame(fTrackSelectionAE, new TGLayoutHints(kLHintsExpandX));
+   fTrackSelectionAE->Connect("Clicked(Int_t)", "AliEveLegoEditor", this, "ShowByTracksAE(Int_t)");
+
+   //**************
+
+   TGHorizontalFrame *horzAE = new TGHorizontalFrame(this2);
+
+   fLabelAE = new TGLabel(horzAE, "Tracks maximum Pt (GeV): ");
+   horzAE->AddFrame(fLabelAE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
+
+   fMaxPtAE = new TGNumberEntry(horzAE, 10000, 7, -1,
+                                  TGNumberFormat::kNESRealOne,
+                                  TGNumberFormat::kNEANonNegative,
+                                  TGNumberFormat::kNELLimitMinMax,
+                                  0, 10000);
+
+   fMaxPtAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetMaxPtAE()");
+
+   horzAE->AddFrame( fMaxPtAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
+   this2->AddFrame(horzAE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
+
+   TGHorizontalFrame *horz1AE = new TGHorizontalFrame(this2);
+
+   fLabel1AE = new TGLabel(horz1AE, "Tracks threshold (GeV): ");
+   horz1AE->AddFrame(fLabel1AE, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
+
+   fThresholdAE = new TGNumberEntry(horz1AE, 0, 7, -1,
+                                  TGNumberFormat::kNESRealOne,
+                                  TGNumberFormat::kNEANonNegative,
+                                  TGNumberFormat::kNELLimitMinMax,
+                                  0, 10000);
+
+   fThresholdAE->Connect("ValueSet(Long_t)", "AliEveLegoEditor", this, "SetThresholdAE()");
+   horz1AE->AddFrame( fThresholdAE, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsCenterY));
+
+   this2->AddFrame(horz1AE, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
+
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowPrevEvent()
+{
+   fM->ShowPrevEvent();
+}
+
+//______________________________________________________________________________
+void AliEveLegoEditor::ShowNextEvent()
+{
+   fM->ShowNextEvent();
+}
+
diff --git a/EVE/EveBase/AliEveLegoEditor.h b/EVE/EveBase/AliEveLegoEditor.h
new file mode 100644 (file)
index 0000000..0270104
--- /dev/null
@@ -0,0 +1,100 @@
+// $Id$
+// Author: Stefano Carrazza 2010
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#ifndef AliEveLegoEditor_H
+#define AliEveLegoEditor_H
+
+#include "TGedFrame.h"
+
+class TGButton;
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+class TGButtonGroup;
+class TGRadioButton;
+class TGLabel;
+class TGComboBox;
+class TGGroupFrame;
+
+class AliEveLego;
+
+//______________________________________________________________________________
+// Short description of AliEveLegoEditor
+//
+
+class AliEveLegoEditor : public TGedFrame
+{
+public:
+   AliEveLegoEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30,
+         UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+   virtual ~AliEveLegoEditor() {}
+
+   virtual void SetModel(TObject* obj);
+
+   // Declare callback/slot methods
+   void DoAllEvents();
+   void ShowByCharge(Int_t id);
+   void ShowByChargeAE(Int_t id);
+   void SetThreshold();
+   void SetThresholdAE();
+   void SetMaxPt();
+   void SetMaxPtAE();
+   void ShowByTracks(Int_t id);
+   void ShowByTracksAE(Int_t id);
+   void ShowByEvents(Int_t id);
+   void ShowEventSelection();
+   void SelectEventSelection(Int_t id);
+   void CreateAllEventsEditor();
+   void ShowPrevEvent();
+   void ShowNextEvent();
+
+protected:
+   AliEveLego            *fM; // Model object.
+
+   // Single event GUI
+   TGTextButton  *fAllEventsButton;
+   TGButtonGroup *fParticlesBG;
+   TGButtonGroup *fTrackSelection;
+   TGGroupFrame *fEventSelection;
+   TGCheckButton *fRevents;
+   TGRadioButton *fRcharge[3];
+   TGRadioButton *fRtracks[2];
+   TGLabel       *fLabel;
+   TGLabel       *fLabel1;
+   TGNumberEntry *fThreshold;
+   TGNumberEntry *fMaxPt;
+   TGComboBox    *fSelect;
+   TGTextButton  *fButtonPrev;
+   TGTextButton  *fButtonNext;
+
+   // All events GUI
+   TGButtonGroup *fParticlesBGAE;
+   TGButtonGroup *fTrackSelectionAE;
+   TGGroupFrame *fEventSelectionAE;
+   TGCheckButton *fReventsAE;
+   TGRadioButton *fRchargeAE[3];
+   TGRadioButton *fRtracksAE[2];
+   TGLabel       *fLabelAE;
+   TGLabel       *fLabel1AE;
+   TGNumberEntry *fThresholdAE;
+   TGNumberEntry *fMaxPtAE;
+   TGComboBox    *fSelectAE;
+   TGTextButton  *fButtonPrevAE;
+   TGTextButton  *fButtonNextAE;
+
+
+private:
+
+   AliEveLegoEditor(const AliEveLegoEditor&);            // Not implemented
+   AliEveLegoEditor& operator=(const AliEveLegoEditor&); // Not implemented
+
+   ClassDef(AliEveLegoEditor, 0); // GUI editor for AliEveLego.
+};
+
+#endif
index daab3a7..f252137 100644 (file)
@@ -84,3 +84,7 @@
 #pragma link C++ class AliEveHFList+;
 #pragma link C++ class AliEveHFEditor+;
 #pragma link C++ class AliEveHFListEditor+;
+
+// AliEveLego
+#pragma link C++ class AliEveLego+;
+#pragma link C++ class AliEveLegoEditor+;
diff --git a/EVE/alice-macros/lego.C b/EVE/alice-macros/lego.C
new file mode 100644 (file)
index 0000000..daddd08
--- /dev/null
@@ -0,0 +1,22 @@
+// Author: Stefano Carrazza 2010
+
+/**************************************************************************
+ * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+AliEveLego* lego(){
+
+   AliEveEventManager *mng = AliEveEventManager::GetMaster();
+   AliEveLego *lego = mng->FindGlobal("LegoHisto2D");
+
+   if ( lego == 0) {
+      lego = new AliEveLego();
+      mng->InsertGlobal("LegoHisto2D",lego);
+   } else {
+      lego->Update();
+   } 
+
+   return lego;
+}
index 54951e5..271e36a 100644 (file)
@@ -139,7 +139,7 @@ void visscan_init(const TString& cdburi = "",
   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks MI",           "esd_tracks.C+", "esd_tracks_MI",           "", kFALSE));
   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by category",  "esd_tracks.C+", "esd_tracks_by_category",  "", kTRUE));
   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks by anal cuts", "esd_tracks.C+", "esd_tracks_by_anal_cuts", "", kFALSE));
-  exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Lego", "histo2d.C", "histo2d", "", kTRUE));
+  exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracks Lego", "lego.C", "lego", "", kTRUE));
 
   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklets SPD", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kTRUE));
 
@@ -234,11 +234,6 @@ void visscan_init(const TString& cdburi = "",
   gEve->EditElement(g_trkcnt);
 
   gEve->Redraw3D(kTRUE);
-
-  // Assure 3D view rotates around the origin.
-  gSystem->ProcessEvents();
-  AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->CurrentCamera().SetCenterVec(0,0,0);
-  AliEveMultiView::Instance()->Get3DView()->GetGLViewer()->RequestDraw();
 }
 
 /******************************************************************************/
@@ -264,12 +259,12 @@ void on_new_event()
 
   AliEveMultiView *mv = AliEveMultiView::Instance();
 
-  // mv->DestroyEventRPhi();
+  //mv->DestroyEventRPhi();
   if (gCenterProjectionsAtPrimaryVertex)
     mv->SetCenterRPhi(x[0], x[1], x[2]);
   mv->ImportEventRPhi(top);
 
-  // mv->DestroyEventRhoZ();
+  //mv->DestroyEventRhoZ();
   if (gCenterProjectionsAtPrimaryVertex)
     mv->SetCenterRhoZ(x[0], x[1], x[2]);
   mv->ImportEventRhoZ(top);