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 281d15da55681fd1b1ff4509cebf471527002bb9..0ddcb13ef883e2fca6f160c1656a487fec6d4030 100644 (file)
@@ -1,21 +1,47 @@
+// $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
 
-Reve::PointSet* its_clusters(RenderElement* cont=0, Float_t maxR=50)
+/**************************************************************************
+ * 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__
+
+class TEveElement;
+class TEvePointSet;
+
+#else
+
+#include <TEveManager.h>
+#include <TEvePointSet.h>
+#include <EveBase/AliEveEventManager.h>
+
+#include <AliRunLoader.h>
+#include <AliCluster.h>
+
+#include <TClonesArray.h>
+
+#endif
+
+TEvePointSet* its_clusters(TEveElement* cont=0, Float_t maxR=50)
 {
-  if (!gGeoManager)
-    gReve->GetGeometry("$PWD/geometry.root");
+  AliEveEventManager::AssertGeometry();
 
-  AliRunLoader* rl = Alieve::Event::AssertRunLoader();
+  AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
   rl->LoadRecPoints("ITS");
 
   TTree *cTree = rl->GetTreeR("ITS", false);
+  if (cTree == 0)
+    return 0;
 
-  Reve::PointSet* clusters = new Reve::PointSet(10000);
-  clusters->SetOwnIds(kTRUE);
-
-  TClonesArray *cl=NULL;
-  TBranch *branch=cTree->GetBranch("ITSRecPoints");
+  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;
@@ -36,14 +62,14 @@ Reve::PointSet* its_clusters(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;
   }
 
   clusters->SetMarkerStyle(2);
-  clusters->SetMarkerSize(0.5);
+  clusters->SetMarkerSize(0.2);
   clusters->SetMarkerColor(4);
 
   char form[1000];
@@ -53,10 +79,8 @@ Reve::PointSet* its_clusters(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);
-  gReve->Redraw3D();
+  gEve->AddElement(clusters, cont);
+  gEve->Redraw3D();
 
   return clusters;
 }