]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/macros/alieve_online_new.C
Offline files disabled in online mode comletely. Problem with creation of Multi View...
[u/mrichter/AliRoot.git] / EVE / macros / alieve_online_new.C
index de725c48694eccbe9a01ed4354d1dda772592638..37518fc3b7ddb6c87927dba0d900f94404ab8006 100644 (file)
  * 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()
 {
-    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")));
-    }
+    // set OCDB path:
+    //AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB"); // default OCDB from aliroot
+    //AliEveEventManager::SetCdbUri("local:///local/OCDB/2013"); // OCDB snapshot for particular run
+    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;
     
-    //AliEveEventManager::SetCdbUri("local://$ALICE_ROOT/OCDB");
-    //AliEveEventManager::SetCdbUri("local:///local/OCDB/2013");
-    AliEveEventManager::SetCdbUri("local:///local/cdb");
-    AliEveEventManager::SetSpecificCdbUri("GRP/GRP/Data","local:///local/reco");
-
-    //AliEveEventManager::SetCdbUri("raw://");
     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.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();
-    
-    AliEveMacroExecutor *exec  = AliEveEventManager::GetMaster()->GetExecutor();
-    TEveBrowser         *browser = gEve->GetBrowser();
+    cout<<"VizDB_scan loaded"<<endl;
+    TEveBrowser *browser = gEve->GetBrowser();
     browser->ShowCloseTab(kFALSE);
+    cout<<"browser created"<<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;
     
-    //These macros crashes on mac os. To be checked. Problems on SLC as well.
-    
-    //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);
-    
+    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");
+    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));
@@ -76,94 +115,68 @@ void alieve_online_new()
     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 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
     //============================================================================
     
-    //
     browser->GetTabRight()->SetTab(1);
     browser->StartEmbedding(TRootBrowser::kBottom);
     new AliEveEventManagerWindow(AliEveEventManager::GetMaster());
     browser->StopEmbedding("EventCtrl");
-//    browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
     
-//    browser->MoveResize(0, 0, gClient->GetDisplayHeight()*1.6,gClient->GetDisplayHeight()-32);
+    browser->MoveResize(0, 0, gClient->GetDisplayWidth(),gClient->GetDisplayHeight() - 32);
     
     gEve->FullRedraw3D(kTRUE);
     gSystem->ProcessEvents();
     
+    // move and rotate sub-views
     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);
+    glv1->CurrentCamera().RotateRad(-0.4, 0.6);
+    glv2->CurrentCamera().Dolly(90, kFALSE, kFALSE);
+    glv3->CurrentCamera().Dolly(1700, kFALSE, kFALSE);
     
     AliEveEventManager::GetMaster()->AddNewEventCommand("alieve_online_on_new_event();");
     gEve->FullRedraw3D();
     gSystem->ProcessEvents();
     gEve->Redraw3D(kTRUE);
     
+    // set autoload by default
     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())
-    {
+      {
+       Double_t x[3] = { 0, 0, 0 };
+
         AliESDEvent* esd = AliEveEventManager::AssertESD();
         esd->GetPrimaryVertex()->GetXYZ(x);
         
@@ -173,67 +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
-       TEveUtil::LoadMacro("saveViews.C");
-       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");
 }
 
@@ -242,8 +257,15 @@ 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);
+  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")));
+       gSystem->ExpandPathName(macdir);
+    }
+    
     
     TFolder* f = gEve->GetMacroFolder();
     void* dirhandle = gSystem->OpenDirectory(macdir.Data());
@@ -252,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));