Geometry for MFT (Brigitte)
[u/mrichter/AliRoot.git] / EVE / alice-macros / phos_clusters.C
index 0330ad3..66e12fd 100644 (file)
@@ -1,40 +1,64 @@
+// $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
 
-Reve::PointSet* phos_clusters(RenderElement* cont=0)
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TObjArray.h>
+#include <TBranch.h>
+#include <TTree.h>
+#include <TString.h>
+#include <TEveManager.h>
+#include <TEveElement.h>
+#include <TEvePointSet.h>
+
+#include <AliCluster.h>
+#include <AliRunLoader.h>
+#include <AliEveEventManager.h>
+#endif
+
+TEvePointSet* phos_clusters(TEveElement* cont=0)
 {
-  if (!gGeoManager)
-    gReve->GetGeometry("$PWD/geometry.root");
+  AliEveEventManager::AssertGeometry();
 
-  AliRunLoader* rl = Alieve::Event::AssertRunLoader();
+  AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
   rl->LoadRecPoints("PHOS");
 
   TTree *cTree = rl->GetTreeR("PHOS", false);
 
-  Reve::PointSet* clusters = new Reve::PointSet(10000);
+       if(!cTree) return 0;
+
+  TEvePointSet* clusters = new TEvePointSet(10000);
   clusters->SetOwnIds(kTRUE);
 
-  TClonesArray *cl=NULL;
+  TObjArray *arr=NULL;
   TBranch *branch=cTree->GetBranch("PHOSEmcRP");
-  branch->SetAddress(&cl);
+  branch->SetAddress(&arr);
 
-  Int_t nentr=(Int_t)cTree->GetEntries();
-  Warning("phos_clusters",Form(" %d"),nentr);
+  Int_t nentr=(Int_t)branch->GetEntries();
   for (Int_t i=0; i<nentr; i++) {
-    if (!cTree->GetEvent(i)) continue;
-
-    Int_t ncl=cl->GetEntriesFast();
+    if (!branch->GetEvent(i)) continue;
 
+    Int_t ncl=arr->GetEntriesFast();
     while (ncl--) {
-      AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
+      AliCluster *cl=(AliCluster*)arr->UncheckedAt(ncl);
+
       Float_t g[3]; //global coordinates
-      c->GetGlobalXYZ(g);
+      cl->GetGlobalXYZ(g);
 
+      AliCluster *atp = new AliCluster(*cl);
       clusters->SetNextPoint(g[0], g[1], g[2]);
-      AliCluster *atp = new AliCluster(*c);
       clusters->SetPointId(atp);
     }
   }
 
-  if(clusters->Size() == 0 && gReve->GetKeepEmptyCont() == kFALSE) {
+  Warning("phos_clusters"," %d", clusters->Size());
+
+  if(clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
     Warning("phos_clusters", "No PHOS clusters");
     delete clusters;
     return 0;
@@ -44,17 +68,17 @@ Reve::PointSet* phos_clusters(RenderElement* cont=0)
   clusters->SetMarkerSize(0.5);
   clusters->SetMarkerColor(4);
 
-  char form[1000];
-  sprintf(form,"PHOS Clusters");
-  clusters->SetName(form);
+  clusters->SetName("PHOS Clusters");
+
+  clusters->SetTitle(Form("N=%d", clusters->Size()));
+
+  const TString viz_tag("REC Clusters PHOS");
+
+  clusters->ApplyVizTag(viz_tag, "Clusters");
 
-  char tip[1000];
-  sprintf(tip,"N=%d", clusters->Size());
-  clusters->SetTitle(tip);
+  gEve->AddElement(clusters);
 
-  using namespace Reve;
-  gReve->AddRenderElement(clusters);
-  gReve->Redraw3D();
+  gEve->Redraw3D();
 
   return clusters;
 }