]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/alice-macros/its_clusters.C
Bug fix in the order of the Ds cuts (Sadhana, Francesco)
[u/mrichter/AliRoot.git] / EVE / alice-macros / its_clusters.C
index f43ee5815266af95ff9cf5cfb23abd9195e816de..8808ee6f01ddce867904f801ec34a506a54b8d03 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 TEveUtil
-{
 class TEveElement;
 class TEvePointSet;
-}
 
 #else
 
-#include <TEve.h>
 #include <TEveManager.h>
 #include <TEvePointSet.h>
-#include <Alieve/EventAlieve.h>
+#include <EveBase/AliEveEventManager.h>
 
 #include <AliRunLoader.h>
 #include <AliCluster.h>
@@ -22,32 +26,43 @@ class TEvePointSet;
 
 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);
-
-  TEvePointSet* clusters = new TEvePointSet(10000);
-  clusters->SetOwnIds(kTRUE);
+  if (cTree == 0)
+    return 0;
 
   TClonesArray *cl = NULL;
   TBranch *branch  = cTree->GetBranch("ITSRecPoints");
   branch->SetAddress(&cl);
 
-  Int_t nentr=(Int_t)cTree->GetEntries();
-  for (Int_t i=0; i<nentr; i++) {
+  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;
 
-    Int_t ncl=cl->GetEntriesFast();
+    Int_t ncl = cl->GetEntriesFast();
 
     Float_t maxRsqr = maxR*maxR;
-    while (ncl--) {
-      AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
+    for (Int_t icl = 0; icl < ncl; ++icl)
+    {
+      AliCluster *c = (AliCluster*) cl->UncheckedAt(icl);
+      // This really should not happen, but did in online display once.
+      if (c == 0)
+      {
+       ::Warning("its_clusters", "Got NULL AliCluster*, idx=%d, N=%d.",
+                 icl, ncl);
+       continue;
+      }
       Float_t g[3]; //global coordinates
       c->GetGlobalXYZ(g);
-      if (g[0]*g[0]+g[1]*g[1] < maxRsqr)
+      if (g[0]*g[0] + g[1]*g[1] < maxRsqr)
       {
        clusters->SetNextPoint(g[0], g[1], g[2]);
        AliCluster *atp = new AliCluster(*c);
@@ -56,24 +71,24 @@ TEvePointSet* its_clusters(TEveElement* cont=0, Float_t maxR=50)
     }
   }
 
+  rl->UnloadRecPoints("ITS");
+
   if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
-    Warning("its_clusters", "No ITS clusters");
+    Warning("its_clusters.C", "No ITS clusters");
     delete clusters;
     return 0;
   }
 
-  clusters->SetMarkerStyle(2);
-  clusters->SetMarkerSize(0.2);
-  clusters->SetMarkerColor(4);
+  clusters->SetName("ITS Clusters");
 
-  char form[1000];
-  sprintf(form,"ITS Clusters");
-  clusters->SetName(form);
+  clusters->SetTitle(Form("N=%d", clusters->Size()));
+
+  const TString viz_tag("REC Clusters ITS");
+
+  clusters->ApplyVizTag(viz_tag, "Clusters");
 
-  char tip[1000];
-  sprintf(tip,"N=%d", clusters->Size());
-  clusters->SetTitle(tip);
   gEve->AddElement(clusters, cont);
+
   gEve->Redraw3D();
 
   return clusters;