Part of fix for Event Display quitting.
authorjniedzie <jeremi.niedziela@cern.ch>
Wed, 8 Oct 2014 09:05:08 +0000 (11:05 +0200)
committerjniedzie <jeremi.niedziela@cern.ch>
Wed, 8 Oct 2014 09:35:59 +0000 (11:35 +0200)
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveMacroExecutorWindow.cxx
EVE/EveBase/AliEveMainWindow.cxx
EVE/EveBase/AliEveMainWindow.h
EVE/macros/alieve_p2.C [new file with mode: 0644]

index 53780a3..35e0e0b 100644 (file)
@@ -171,18 +171,22 @@ AliEveEventManager::~AliEveEventManager()
     fAutoLoadTimer->Stop();
     fAutoLoadTimer->Disconnect("Timeout");
 
-    delete fSubManagers;
+    AliEveEventManager *manager = AliEveEventManager::GetCurrent();
+    manager->Disconnect("StorageManagerOk");
+    manager->Disconnect("StorageManagerDown");
+
+    if(fSubManagers){delete fSubManagers;}
 
     if (fIsOpen)
     {
         Close();
     }
 
-    fTransients->DecDenyDestroy();
-    fTransients->Destroy();
+//    fTransients->DecDenyDestroy();
+//    fTransients->Destroy();
 
-    fTransientLists->DecDenyDestroy();
-    fTransientLists->Destroy();
+//    fTransientLists->DecDenyDestroy();
+//    fTransientLists->Destroy();
 
     //delete fExecutor;
 }
index 6d9ac10..ec9a119 100644 (file)
@@ -175,8 +175,7 @@ AliEveMacroExecutorWindow::~AliEveMacroExecutorWindow()
 {
   // Destructor.
        fBoxContents.clear();
-               
-  AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
+    AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded");/*()", this);*/
 }
 
 /******************************************************************************/
index bf03cac..23437e9 100644 (file)
@@ -43,7 +43,7 @@ AliEveMainWindow::AliEveMainWindow(const char* title, UInt_t width, UInt_t heigh
       fMenuHelp(0),
       fToolBar(0),
       fPicturePool(0),
-      fEve(0),
+//      fEve(0),
       fFileDialog(0)
 {
        static const TEveException kEH("AliEveMainWindow");
@@ -52,7 +52,7 @@ AliEveMainWindow::AliEveMainWindow(const char* title, UInt_t width, UInt_t heigh
     AliEveUtil::Init();
     fPicturePool = AliEveUtil::GetPicturePool();
    
-    fEve = TEveManager::Create(kFALSE, "VVV");
+//    fEve = TEveManager::Create(kFALSE, "VVV");
     gEve->GetDefaultViewer()->SetElementName("3D View");
     gEve->GetSelection()->SetPickToSelect(TEveSelection::kPS_PableCompound);
     gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_PableCompound);
@@ -86,7 +86,7 @@ AliEveMainWindow::AliEveMainWindow(const char* title, UInt_t width, UInt_t heigh
 
 AliEveMainWindow::~AliEveMainWindow()
 {
-    if(fEve) delete fEve;
+//    if(fEve) delete fEve;
 }
 
 void AliEveMainWindow::onMenuFileItem(UInt_t id)
index fa021a8..20c74da 100644 (file)
@@ -102,7 +102,7 @@ private:
 
     TGPicturePool* fPicturePool;
 
-    TEveManager* fEve;
+//    TEveManager* fEve;
     AliEveFileDialog* fFileDialog;
 
     ClassDef(AliEveMainWindow, 0); // Short description.
diff --git a/EVE/macros/alieve_p2.C b/EVE/macros/alieve_p2.C
new file mode 100644 (file)
index 0000000..3902aa9
--- /dev/null
@@ -0,0 +1,277 @@
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+class TEveProjectionManager;
+class TEveGeoShape;
+class TEveUtil;
+class AliTriggerAnalysis;
+class AliSysInfo;
+
+TH2D* V0StateHistogram;
+
+Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
+
+bool gBlackBackground = true;
+
+void alieve_p2()
+{
+    printf("alieve_online_init() ...\n");
+    
+    if (gSystem->Getenv("ALICE_ROOT") != 0)
+    {
+        gInterpreter->AddIncludePath(Form("%s/MUON", gSystem->Getenv("ALICE_ROOT")));
+        gInterpreter->AddIncludePath(Form("%s/MUON/mapping", gSystem->Getenv("ALICE_ROOT")));
+    }
+    
+    AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB");
+    
+    Info("alieve_init", "Adding standard macros.");
+    TString  hack = gSystem->pwd(); // Problem with TGFileBrowser cding
+    alieve_init_import_macros();
+    gSystem->cd(hack);
+    
+    new AliEveEventManager("online", -1);
+    gEve->AddEvent(AliEveEventManager::GetMaster());
+    
+    TEveUtil::AssertMacro("VizDB_scan_p2.C");
+//    gSystem->ProcessEvents();
+    
+    AliEveMacroExecutor *exec  = AliEveEventManager::GetMaster()->GetExecutor();
+    TEveBrowser         *browser = gEve->GetBrowser();
+    browser->ShowCloseTab(kFALSE);
+    
+    // Gentle-geom loading changes gGeoManager.
+    AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
+    
+    TEveUtil::LoadMacro("geom_gentle.C");
+    multiView->InitGeomGentle(geom_gentle(),
+                              geom_gentle_rphi(),
+                              geom_gentle_rhoz(),
+                              geom_gentle_rhoz());
+    
+    
+    
+    //These macros crashes on mac os. To be checked
+    
+    TEveUtil::LoadMacro("geom_gentle_trd.C");
+//    multiView->InitGeomGentleTrd(geom_gentle_trd());
+    
+    TEveUtil::LoadMacro("geom_gentle_muon.C");
+    //multiView->InitGeomGentleMuon(geom_gentle_muon(), kFALSE, kFALSE, kTRUE);
+    
+    //============================================================================
+    // Standard macros to execute -- not all are enabled by default.
+    //============================================================================
+    
+    printf("============ Setting macro executor\n");
+    
+    AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
+    
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex",             "",                kTRUE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse",     "",                kTRUE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box",         "kFALSE, 3, 3, 3", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_spd",         "",                kTRUE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "",                kTRUE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_spd",     "kFALSE, 3, 3, 3", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_tpc",         "",                kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "",                kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_tpc",     "kFALSE, 3, 3, 3", kFALSE));
+    
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS",   "its_clusters.C",   "its_clusters"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC",   "tpc_clusters.C",   "tpc_clusters"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD",   "trd_clusters.C",   "trd_clusters"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF",   "tof_clusters.C",   "tof_clusters"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus HMPID", "hmpid_clusters.C", "hmpid_clusters"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus MUON",  "muon_clusters.C",  "muon_clusters"));
+    
+    
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG EMCAL",   "emcal_digits.C",   "emcal_digits"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ITS",     "its_raw.C",     "its_raw"));
+    //  exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TOF",     "tof_raw.C",     "tof_raw"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw", "", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw", "", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW MUON",    "muon_raw.C",  "muon_raw"));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD",     "fmd_raw.C",     "fmd_raw"));
+    
+    
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track",      "esd_tracks.C",        "esd_tracks",             "", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track",      "esd_tracks.C",        "esd_tracks_MI",          "", kFALSE));
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track MUON", "esd_muon_tracks.C", "esd_muon_tracks",        "kTRUE,kFALSE", kTRUE));
+    
+    
+    // these macros were leaking:
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track",      "esd_tracks.C",        "esd_tracks_by_category", "", kTRUE));// just a little
+    exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC FMD",        "fmd_esd.C",           "fmd_esd",                "", kTRUE));//huge leak
+    //
+    
+    
+    
+    // ???
+    // exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC TRD", "trd_detectors.C", "trd_detectors",         "", kFALSE));
+    // trd_tracks disabled due to memory leaks
+    
+    //----------------------------------------------------------------------------
+    
+    slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
+    slot->StartEmbedding();
+    AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
+    slot->StopEmbedding("DataSelection");
+    exewin->PopulateMacros();
+    
+    //============================================================================
+    // Final GUI setup
+    //============================================================================
+    
+    browser->GetTabRight()->SetTab(1);
+    browser->StartEmbedding(TRootBrowser::kBottom);
+    new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
+    browser->StopEmbedding("EventCtrl");
+    
+    browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
+    
+    if(!gBlackBackground) gEve->GetViewers()->SwitchColorSet();
+    
+//    browser->HideFrame(browser->GetTabLeft());
+//    browser->HideFrame(browser->GetTabRight());
+//    browser->HideFrame(TRootBrowser::kBottom);
+//    browser->GetMainFrame()->HideFrame(browser->GetTabRight());
+    
+    gEve->FullRedraw3D(kTRUE);
+//    gSystem->ProcessEvents();
+    
+    TGLViewer *glv1 = multiView->Get3DView()->GetGLViewer();
+    TGLViewer *glv2 = multiView->GetRPhiView()->GetGLViewer();
+    TGLViewer *glv3 = multiView->GetRhoZView()->GetGLViewer();
+    
+    glv1->CurrentCamera().RotateRad(-0.4, -1.8);
+    glv2->CurrentCamera().Dolly(450, kFALSE, kFALSE);
+    glv3->CurrentCamera().Dolly(1500, kFALSE, kFALSE);
+    
+    AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event();");
+    
+//    gEve->FullRedraw3D();
+    gSystem->ProcessEvents();
+    gEve->Redraw3D(kTRUE);
+    
+    gEve->GetBrowser()->RaiseWindow();
+    gEve->FullRedraw3D();
+    gSystem->ProcessEvents();
+
+/*
+    printf("\n\nfound:%p\n\n",gEve->GetViewers()->FindChild("Multi View"));
+    
+    TEveViewer *multiViewer = dynamic_cast<TEveViewer*>(gEve->GetViewers()->FindChild("3D View"));
+    
+    if(multiViewer)
+    {
+        printf("\n\nMulti view:%p\n\n",multiViewer);
+        multiViewer->UndockWindow();
+    }
+    else
+    {
+        printf("\n\nMulti view not found\n\n");
+    }
+  */
+    // add some margins for the borders and the WM decorations/title
+//    multiView->MoveResize(0, 0, gClient->GetDisplayWidth(), gClient->GetDisplayHeight());
+    
+    AliEveEventManager::GetMaster()->SetAutoLoad(true);
+}
+
+Int_t      g_pic_id  = 0;
+Int_t      g_pic_max = 100;
+TTimeStamp g_pic_prev(0, 0);
+
+void alieve_online_on_new_event()
+{
+    AliSysInfo::AddStamp("on_new_event_start");
+    
+    Double_t x[3] = { 0, 0, 0 };
+    
+    if (AliEveEventManager::HasESD())
+    {
+        AliESDEvent* esd = AliEveEventManager::AssertESD();
+        esd->GetPrimaryVertex()->GetXYZ(x);
+        
+        TTimeStamp ts(esd->GetTimeStamp());
+        TString win_title("Eve Main Window -- Timestamp: ");
+        win_title += ts.AsString("s");
+        win_title += "; Event # in ESD file: ";
+        win_title += esd->GetEventNumberInFile();
+        gEve->GetBrowser()->SetWindowName(win_title);
+    }
+    
+    TEveElement* top = gEve->GetCurrentEvent();
+    
+    AliEveMultiView *mv = AliEveMultiView::Instance();
+    
+    //mv->DestroyEventRPhi();
+    if (gCenterProjectionsAtPrimaryVertex)
+        mv->SetCenterRPhi(x[0], x[1], x[2]);
+    mv->ImportEventRPhi(top);
+    
+    //mv->DestroyEventRhoZ();
+    if (gCenterProjectionsAtPrimaryVertex)
+        mv->SetCenterRhoZ(x[0], x[1], x[2]);
+    mv->ImportEventRhoZ(top);
+    
+    if (gCenterProjectionsAtPrimaryVertex)
+        mv->SetCenterMuon(x[0], x[1], x[2]);
+    mv->ImportEventMuon(top);
+    
+    AliSysInfo::AddStamp("on_new_event_end");
+}
+
+void alieve_init_import_macros()
+{
+    // Put macros in the list of browsables, add a macro browser to
+    // top-level GUI.
+    
+    TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
+    gSystem->ExpandPathName(macdir);
+    
+    TFolder* f = gEve->GetMacroFolder();
+    void* dirhandle = gSystem->OpenDirectory(macdir.Data());
+    if (dirhandle != 0)
+    {
+        char* filename;
+        TPMERegexp re("\\.C$");
+        TObjArray names;
+        while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
+        {
+            if (re.Match(filename))
+                names.AddLast(new TObjString(filename));
+        }
+        names.Sort();
+        
+        for (Int_t ii=0; ii<names.GetEntries(); ++ii)
+        {
+            TObjString * si = (TObjString*) names.At(ii);
+            f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
+        }
+    }
+    gSystem->FreeDirectory(dirhandle);
+    
+    gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
+    
+    {
+        TEveBrowser   *br = gEve->GetBrowser();
+        TGFileBrowser *fb = 0;
+        fb = br->GetFileBrowser();
+        fb->GotoDir(macdir);
+        {
+            br->StartEmbedding(0);
+            fb = br->MakeFileBrowser();
+            fb->BrowseObj(f);
+            fb->Show();
+            br->StopEmbedding();
+            br->SetTabTitle("Macros", 0);
+            br->SetTab(0, 0);
+        }
+    }
+}