Handle missing rec-point tree in a uniform way: return null pointer to TEvePointSet.
[u/mrichter/AliRoot.git] / EVE / alice-macros / its_clusters.C
index 353a83fae7628fd55f68ea705576b97039f6cc8b..0ddcb13ef883e2fca6f160c1656a487fec6d4030 100644 (file)
@@ -1,17 +1,21 @@
+// $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
+
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
 #ifdef __CINT__
 
-namespace Reve
-{
-class RenderElement;
-class PointSet;
-}
+class TEveElement;
+class TEvePointSet;
 
 #else
 
-#include <Reve/Reve.h>
-#include <Reve/ReveManager.h>
-#include <Reve/PointSet.h>
-#include <Alieve/EventAlieve.h>
+#include <TEveManager.h>
+#include <TEvePointSet.h>
+#include <EveBase/AliEveEventManager.h>
 
 #include <AliRunLoader.h>
 #include <AliCluster.h>
@@ -20,22 +24,24 @@ class PointSet;
 
 #endif
 
-Reve::PointSet* its_clusters(Reve::RenderElement* cont=0, Float_t maxR=50)
+TEvePointSet* its_clusters(TEveElement* cont=0, Float_t maxR=50)
 {
-  Alieve::Event::AssertGeometry();
+  AliEveEventManager::AssertGeometry();
 
-  AliRunLoader* rl = Alieve::Event::AssertRunLoader();
+  AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
   rl->LoadRecPoints("ITS");
 
   TTree *cTree = rl->GetTreeR("ITS", false);
-
-  Reve::PointSet* clusters = new Reve::PointSet(10000);
-  clusters->SetOwnIds(kTRUE);
+  if (cTree == 0)
+    return 0;
 
   TClonesArray *cl = NULL;
   TBranch *branch  = cTree->GetBranch("ITSRecPoints");
   branch->SetAddress(&cl);
 
+  TEvePointSet* clusters = new TEvePointSet(10000);
+  clusters->SetOwnIds(kTRUE);
+
   Int_t nentr=(Int_t)cTree->GetEntries();
   for (Int_t i=0; i<nentr; i++) {
     if (!cTree->GetEvent(i)) continue;
@@ -56,8 +62,8 @@ Reve::PointSet* its_clusters(Reve::RenderElement* cont=0, Float_t maxR=50)
     }
   }
 
-  if(clusters->Size() == 0 && gReve->GetKeepEmptyCont() == kFALSE) {
-    Warning("its_clusters", "No ITS clusters");
+  if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
+    Warning("its_clusters.C", "No ITS clusters");
     delete clusters;
     return 0;
   }
@@ -73,10 +79,8 @@ Reve::PointSet* its_clusters(Reve::RenderElement* cont=0, Float_t maxR=50)
   char tip[1000];
   sprintf(tip,"N=%d", clusters->Size());
   clusters->SetTitle(tip);
-
-  using namespace Reve;
-  gReve->AddRenderElement(clusters, cont);
-  gReve->Redraw3D();
+  gEve->AddElement(clusters, cont);
+  gEve->Redraw3D();
 
   return clusters;
 }