Offline files disabled in online mode comletely. Problem with creation of Multi View...
[u/mrichter/AliRoot.git] / EVE / macros / alieve_online_new.C
index 73d5891..37518fc 100644 (file)
@@ -4,19 +4,48 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
+#include "AliEveEventManager.h"
+#include "AliEveEventManagerEditor.h"
+#include "AliEveMultiView.h"
+#include "AliEveMacroExecutor.h"
+#include "AliEveMacro.h"
+#include "AliSysInfo.h"
+
+#include <TH2D.h>
+#include <TTimeStamp.h>
+#include <TROOT.h>
+#include <TEveManager.h>
+#include <TEveBrowser.h>
+#include <TEveMacro.h>
+#include <TGTab.h>
+#include <TGFileBrowser.h>
+#include <TInterpreter.h>
+#include <TEnv.h>
+#include <TPRegexp.h>
+#include <TFolder.h>
+#include <TSystem.h>
+#include <TSystemDirectory.h>
+#include <TList.h>
+
+#include <iostream>
+
+using namespace std;
+
 class TEveProjectionManager;
 class TEveGeoShape;
 class TEveUtil;
 class AliTriggerAnalysis;
 class AliSysInfo;
 
-TH2D* V0StateHistogram;
+TH2D *V0StateHistogram;
 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
 
 Int_t      g_pic_id  = 0;
 Int_t      g_pic_max = 100;
 TTimeStamp g_pic_prev(0, 0);
 
+void alieve_init_import_macros();
+
 void alieve_online_new()
 {
     // set OCDB path:
@@ -25,35 +54,42 @@ void alieve_online_new()
     AliEveEventManager::SetCdbUri("local:///local/cdb");         // current OCDB snapshot
     //AliEveEventManager::SetCdbUri("raw://");                   // reading OCDB from alien
     
+    cout<<"Creating multiview...";
+    AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
+    cout<<"created"<<endl;
     
     Info("alieve_init", "Adding standard macros.");
     TString  hack = gSystem->pwd(); // Problem with TGFileBrowser cding
     alieve_init_import_macros();
     gSystem->cd(Form("%s/../src/",gSystem->Getenv("ALICE_ROOT")));
-    gROOT->ProcessLine(".L saveViews.C++");
-    gROOT->ProcessLine(".L geom_gentle_muon.C++");
-    gROOT->ProcessLine(".L geom_gentle_trd.C++");
+    gROOT->ProcessLine(".L saveViews.C+");
+    gROOT->ProcessLine(".L geom_gentle.C+");
+    gROOT->ProcessLine(".L geom_gentle_muon.C+");
+    gROOT->ProcessLine(".L geom_gentle_trd.C+");
     TEveUtil::LoadMacro("saveViews.C");
     gSystem->cd(hack);
     cout<<"Standard macros added"<<endl;
     
+
     new AliEveEventManager("online", -1);
     gEve->AddEvent(AliEveEventManager::GetMaster());
+    cout<<"Event manager created"<<endl;
     
     TEveUtil::AssertMacro("VizDB_scan.C");
     gSystem->ProcessEvents();
-    
+    cout<<"VizDB_scan loaded"<<endl;
     TEveBrowser *browser = gEve->GetBrowser();
     browser->ShowCloseTab(kFALSE);
+    cout<<"browser created"<<endl;
     
-
-    cout<<"Creating multiview"<<endl;
-    AliEveMultiView *multiView = new AliEveMultiView(kTRUE);
     TEveUtil::LoadMacro("geom_gentle.C");
+    cout<<"geom gentle loaded"<<endl;
+    
     multiView->InitGeomGentle(geom_gentle(),
                               geom_gentle_rphi(),
                               geom_gentle_rhoz(),
                               geom_gentle_rhoz());
+    cout<<"geom gentl inited"<<endl;
     
     TEveUtil::LoadMacro("geom_gentle_trd.C");
     multiView->InitGeomGentleTrd(geom_gentle_trd());
@@ -68,7 +104,8 @@ void alieve_online_new()
     printf("============ Setting macro executor ============\n");
     
     AliEveMacroExecutor *exec = AliEveEventManager::GetMaster()->GetExecutor();
-    
+    printf("exec created\n");
+    /*
     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));
@@ -81,24 +118,25 @@ void alieve_online_new()
     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 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
-    
+    cout<<"macros added to exec"<<endl;
+
     //----------------------------------------------------------------------------
-    
+    /* something is wrong here:
     slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
     slot->StartEmbedding();
     AliEveMacroExecutorWindow* exewin = new AliEveMacroExecutorWindow(exec);
     slot->StopEmbedding("DataSelection");
     exewin->PopulateMacros();
-    
+    */
     //============================================================================
     // Final GUI setup
     //============================================================================
@@ -107,7 +145,7 @@ void alieve_online_new()
     browser->StartEmbedding(TRootBrowser::kBottom);
     new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
     browser->StopEmbedding("EventCtrl");
+    
     browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
     
     gEve->FullRedraw3D(kTRUE);
@@ -134,11 +172,11 @@ void alieve_online_new()
 void alieve_online_on_new_event()
 {
     AliSysInfo::AddStamp("on_new_event_start");
-    
-    Double_t x[3] = { 0, 0, 0 };
-    
+       
     if (AliEveEventManager::HasESD())
-    {
+      {
+       Double_t x[3] = { 0, 0, 0 };
+
         AliESDEvent* esd = AliEveEventManager::AssertESD();
         esd->GetPrimaryVertex()->GetXYZ(x);
         
@@ -148,66 +186,69 @@ void alieve_online_on_new_event()
         win_title += "; Event # in ESD file: ";
         win_title += esd->GetEventNumberInFile();
         gEve->GetBrowser()->SetWindowName(win_title);
-    }
     
-    TEveElement* top = gEve->GetCurrentEvent();
     
-    AliEveMultiView *mv = AliEveMultiView::Instance();
+       TEveElement* top = gEve->GetCurrentEvent();
+    
+       AliEveMultiView *mv = AliEveMultiView::Instance();
     
-    //mv->DestroyEventRPhi();
-    if (gCenterProjectionsAtPrimaryVertex)
-        mv->SetCenterRPhi(x[0], x[1], x[2]);
-    mv->ImportEventRPhi(top);
+       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);
+       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);
+       if (gCenterProjectionsAtPrimaryVertex)
+         mv->SetCenterMuon(x[0], x[1], x[2]);
+       mv->ImportEventMuon(top);
     
     
-     // Register image to amore.
-     // const TString pichost("aldaqacrs3");
-     const TString pichost(gEnv->GetValue("AliEve.imageDumpHost", "localhost"));
-     TTimeStamp now;
-     Double_t delta = now.AsDouble() - g_pic_prev.AsDouble();
+       // Register image to amore.
+       // const TString pichost("aldaqacrs3");
+       const TString pichost(gEnv->GetValue("AliEve.imageDumpHost", "localhost"));
+       TTimeStamp now;
+       Double_t delta = now.AsDouble() - g_pic_prev.AsDouble();
      
-     printf("Pre image dump: host='%s', delta=%f.\n",gSystem->HostName(), delta);
+       printf("Pre image dump: host='%s', delta=%f.\n",gSystem->HostName(), delta);
      
-     AliSysInfo::AddStamp("on_new_event_pic");
-     // if (pichost == gSystem->HostName() && delta >= 30)
-     {
-       TString id;      id.Form("online-viz-%03d", g_pic_id);
-       TString pic(id); pic += ".png";
+       AliSysInfo::AddStamp("on_new_event_pic");
+       // if (pichost == gSystem->HostName() && delta >= 30)
+       {
+         TString id;      id.Form("online-viz-%03d", g_pic_id);
+         TString pic(id); pic += ".png";
      
-       printf("In image dump: file='%s'.\n", pic.Data());
+         printf("In image dump: file='%s'.\n", pic.Data());
      
-       gEve->GetBrowser()->RaiseWindow();
-       gEve->FullRedraw3D();
-       gSystem->ProcessEvents();
+         gEve->GetBrowser()->RaiseWindow();
+         gEve->FullRedraw3D();
+         gSystem->ProcessEvents();
      
-       Int_t status;
+         Int_t status;
      
-       // create screenshots from OpenGL views
-       saveViews(pic.Data());
+         // create screenshots from OpenGL views
+         saveViews(pic.Data());
      
-       // send screenshot to AMORE
-       cout<<"Sending:"<<TString::Format("SendImageToAmore %s %s %d",id.Data(), pic.Data(),AliEveEventManager::AssertESD()->GetRunNumber())<<endl;
+         // send screenshot to AMORE
+         cout<<"Sending:"<<TString::Format("SendImageToAmore %s %s %d",id.Data(), pic.Data(),AliEveEventManager::AssertESD()->GetRunNumber())<<endl;
 
-       status = gSystem->Exec(TString::Format("SendImageToAmore %s %s %d",
-                                             id.Data(), pic.Data(),
-                                             AliEveEventManager::AssertESD()->GetRunNumber()));
+         status = gSystem->Exec(TString::Format("SendImageToAmore %s %s %d",
+                                                id.Data(), pic.Data(),
+                                                AliEveEventManager::AssertESD()->GetRunNumber()));
      
-       printf("Post AMORE reg -- status=%d, run=%d.\n", status,
-             AliEveEventManager::AssertESD()->GetRunNumber());
+         printf("Post AMORE reg -- status=%d, run=%d.\n", status,
+                AliEveEventManager::AssertESD()->GetRunNumber());
      
-       if (++g_pic_id >= g_pic_max)
-        g_pic_id = 0;
-       g_pic_prev.Set();
-     }
+         if (++g_pic_id >= g_pic_max)
+           g_pic_id = 0;
+         g_pic_prev.Set();
+       }
+      }
     AliSysInfo::AddStamp("on_new_event_end");
 }
 
@@ -216,12 +257,13 @@ 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");
+
     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")));
-        TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
-        gSystem->ExpandPathName(macdir);
+       gSystem->ExpandPathName(macdir);
     }
     
     
@@ -232,7 +274,7 @@ void alieve_init_import_macros()
         char* filename;
         TPMERegexp re("\\.C$");
         TObjArray names;
-        while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
+        while ((filename = (char*)(gSystem->GetDirEntry(dirhandle))) != 0)
         {
             if (re.Match(filename))
                 names.AddLast(new TObjString(filename));