]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/macros/alieve_init.C
Memory leaks removal
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
index 48f5018490cda47bef7c1a1395ebd495e3453c29..aa7a34a131c0df47f963b266cfd08c6a958a467e 100644 (file)
@@ -7,37 +7,66 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
-#ifndef __CINT_
-#include <list>
-#include <string>
-#endif
-
-// !!!!! Need initialization that will also work for raw.
-// Path and event-id are usually not needed.
-// const Text_t* raw_file = 0,
-
-void alieve_init(const Text_t* path   = ".", Int_t event=0,
-                const Text_t* cdburi = 0,
-                Bool_t assert_runloader=kFALSE, Bool_t assert_esd=kFALSE)
+void alieve_init(const TString& cdburi = "",
+                const TString& path   = ".", Int_t event=0,
+                 const Text_t* esdfile = 0,
+                 const Text_t* aodfile = 0,
+                 const Text_t* rawfile = 0,
+                Bool_t assert_runloader = kFALSE,
+                 Bool_t assert_esd       = kFALSE,
+                 Bool_t assert_aod       = kFALSE,
+                 Bool_t assert_raw       = kFALSE)
 {
+  if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
+  {
+    gEnv->SetValue("Root.Stacktrace", "no");
+    Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument.");
+  }
+
   Info("alieve_init", "Adding standard macros.");
   TString  hack = gSystem->pwd(); // Problem with TGFileBrowser cding
   alieve_init_import_macros();
   gSystem->cd(hack);
 
-  // TEveUtil::AssertMacro("region_marker.C");
+  alieve_init_basic_vizdb();
+  // Temporarily assert also default vizdb.
+  TEveUtil::AssertMacro("VizDB_scan.C");
 
   gSystem->ProcessEvents();
 
+  AliEveEventManager::SetESDFileName(esdfile);
+  AliEveEventManager::SetRawFileName(rawfile);
+  AliEveEventManager::SetCdbUri(cdburi);
+  AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
+                                       assert_aod, assert_raw);
+
   // Open event
-  if(path != 0) {
-    AliEveEventManager::SetCdbUri(cdburi);
-    AliEveEventManager::SetAssertElements(assert_runloader, assert_esd);
-    printf("Opening event %d from '%s' ...", event, path); fflush(stdout);
-    gEvent = new AliEveEventManager(path, event);
-    printf(" done.\n");
-    gEve->AddEvent(gEvent);
+  if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
+  {
+    if (gGrid != 0)
+    {
+      Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
+    }
+    else
+    {
+      Info("alieve_init", "AliEn requested - connecting.");
+      if (gSystem->Getenv("alien_API_VO") == 0)
+      {
+       Error("alieve_init", "AliEn environment not initialized. Aborting.");
+       gSystem->Exit(1);
+      }
+      if (TGrid::Connect("alien") == 0)
+      {
+       Error("alieve_init", "TGrid::Connect() failed. Aborting.");
+       gSystem->Exit(1);
+      }
+    }
   }
+
+  Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data());
+  TString name("Event"); // CINT has trouble with direct "Event".
+  new AliEveEventManager(name, path, event);
+  gEve->AddEvent(AliEveEventManager::GetMaster());
 }
 
 void alieve_init_import_macros()
@@ -45,19 +74,20 @@ void alieve_init_import_macros()
   // Put macros in the list of browsables, add a macro browser to
   // top-level GUI.
 
-  TString macdir("$(REVESYS)/alice-macros");
+  TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
   gSystem->ExpandPathName(macdir);
 
   TFolder* f = gEve->GetMacroFolder();
   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
-  if(dirhandle != 0) {
+  if (dirhandle != 0)
+  {
     char* filename;
-    TPRegexp re("\.C$");
-    std::list<string> names;
-    while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
-      if(re.Match(filename)) {
+    TPMERegexp re("\\.C$");
+    std::list<string> names; // This form understood by cint (fails with std::string).
+    while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
+    {
+      if (re.Match(filename))
        names.push_back(filename);
-      }
     }
     names.sort();
     //PH The line below is replaced waiting for a fix in Root
@@ -93,3 +123,14 @@ void alieve_init_import_macros()
     }
   }
 }
+
+void alieve_init_basic_vizdb()
+{
+  TEvePointSet* ps;
+
+  ps = new TEvePointSet();
+  ps->SetMarkerColor(4);
+  ps->SetMarkerSize(0.2);
+  ps->SetMarkerStyle(2);
+  gEve->InsertVizDBEntry("Clusters", ps);
+}