]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/alice-macros/tpc_clusters.C
alieve_online.C - added camera checking (for shrinking views problem)
[u/mrichter/AliRoot.git] / EVE / alice-macros / tpc_clusters.C
index d3ae171563f4030e60abe53e5b6f9378cec84f77..64f78c6518a668de9050bec643813844cc8d5595 100644 (file)
@@ -1,37 +1,96 @@
+// $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
 
-Reve::PointSet* tpc_clusters(RenderElement* cont=0, Float_t maxR=270)
+/**************************************************************************
+ * 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 <TColor.h>
+#include <TEvePointSet.h>
+#include <EveBase/AliEveEventManager.h>
+
+#include <AliRunLoader.h>
+#include <AliCluster.h>
+#include <TPC/AliTPCClustersRow.h>
+#include <TPC/AliTPCclusterMI.h>
+
+#endif
+
+TEvePointSet* tpc_clusters(TEveElement* cont=0, Float_t maxR=270)
 {
+
   const Int_t kMaxCl=100*160;
 
-  Alieve::Event::AssertGeometry();
+  Int_t fNColorBins = 5;
 
-  Reve::PointSet* clusters = new Reve::PointSet(kMaxCl);
-  clusters->SetOwnIds(kTRUE);
+  AliEveEventManager::AssertGeometry();
 
-  AliRunLoader* rl = Alieve::Event::AssertRunLoader();
+  AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
   rl->LoadRecPoints("TPC");
 
-  AliTPCClustersRow *clrow=new AliTPCClustersRow();
+  TTree *cTree = rl->GetTreeR("TPC", false);
+  if (cTree == 0)
+    return 0;
+
+  AliTPCClustersRow *clrow = new AliTPCClustersRow();
   clrow->SetClass("AliTPCclusterMI");
   clrow->SetArray(kMaxCl);
+  cTree->SetBranchAddress("Segment", &clrow);
 
-  TTree *cTree = rl->GetTreeR("TPC", false);
-  TBranch *branch=cTree->SetBranchAddress("Segment",&clrow);
+  TEvePointSet* clusters = new TEvePointSet(kMaxCl);
+  clusters->SetOwnIds(kTRUE);
+
+  TEvePointSetArray * cc = new TEvePointSetArray("TPC Clusters Colorized");
+  cc->SetMainColor(kRed);
+  cc->SetMarkerStyle(4);
+  cc->SetMarkerSize(0.4);
+  cc->InitBins("Cluster Charge", fNColorBins, 0., fNColorBins*60.);
+  
+  cc->GetBin(0)->SetMainColor(kGray);
+  cc->GetBin(0)->SetMarkerSize(0.4);
+  cc->GetBin(1)->SetMainColor(kBlue);
+  cc->GetBin(1)->SetMarkerSize(0.42);
+  cc->GetBin(2)->SetMainColor(kCyan);
+  cc->GetBin(2)->SetMarkerSize(0.44);
+  cc->GetBin(3)->SetMainColor(kGreen);
+  cc->GetBin(3)->SetMarkerSize(0.46);
+  cc->GetBin(4)->SetMainColor(kYellow);
+  cc->GetBin(4)->SetMarkerSize(0.48);
+  cc->GetBin(5)->SetMainColor(kRed);
+  cc->GetBin(5)->SetMarkerSize(0.50);
+  cc->GetBin(6)->SetMainColor(kMagenta);
+  cc->GetBin(6)->SetMarkerSize(0.52);
 
   Float_t maxRsqr = maxR*maxR;
-  TClonesArray *cl=clrow->GetArray(); 
   Int_t nentr=(Int_t)cTree->GetEntries();
-  for (Int_t i=0; i<nentr; i++) {
+  for (Int_t i=0; i<nentr; i++)
+  {
     if (!cTree->GetEvent(i)) continue;
 
-    Int_t ncl=cl->GetEntriesFast();
+    TClonesArray *cl = clrow->GetArray();
+    Int_t ncl = cl->GetEntriesFast();
 
-    while (ncl--) {
-      AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
+    while (ncl--)
+    {
+
+      AliTPCclusterMI* clusterMi = (AliTPCclusterMI*) cl->At(ncl);
+
+      AliCluster *c = (AliCluster*) cl->UncheckedAt(ncl);
       Float_t g[3]; //global coordinates
       c->GetGlobalXYZ(g);
       if (g[0]*g[0]+g[1]*g[1] < maxRsqr)
       {
+        cc->Fill(g[0], g[1], g[2], clusterMi->GetQ());
        clusters->SetNextPoint(g[0], g[1], g[2]);
        AliCluster *atp = new AliCluster(*c);
        clusters->SetPointId(atp);
@@ -42,27 +101,33 @@ Reve::PointSet* tpc_clusters(RenderElement* cont=0, Float_t maxR=270)
 
   delete clrow;
 
-  if(clusters->Size() == 0 && gReve->GetKeepEmptyCont() == kFALSE) {
-    Warning("tpc_clusters", "No TPC clusters");
+  rl->UnloadRecPoints("TPC");
+
+  if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE)
+  {
+    Warning("tpc_clusters.C", "No TPC clusters");
     delete clusters;
     return 0;
   }
 
-  clusters->SetMarkerStyle(2);
-  clusters->SetMarkerSize(0.2);
-  clusters->SetMarkerColor(4);
+  clusters->SetName("TPC Clusters");
+
+  clusters->SetTitle(Form("N=%d", clusters->Size()));
+
+  const TString viz_tag("REC Clusters TPC");
+
+  clusters->ApplyVizTag(viz_tag, "Clusters");
+
+//  clusters->SetRnrSelf(kFALSE);
+//  clusters->SetRnrChildren(kFALSE);    
+
+//  gEve->AddElement(clusters, cont);
 
-  char form[1000];
-  sprintf(form,"TPC Clusters");
-  clusters->SetName(form);
+  cc->SetRnrSelf(kTRUE);
 
-  char tip[1000];
-  sprintf(tip,"N=%d", clusters->Size());
-  clusters->SetTitle(tip);
+  gEve->AddElement(cc);
 
-  using namespace Reve;
-  gReve->AddRenderElement(clusters);
-  gReve->Redraw3D();
+  gEve->Redraw3D();
 
   return clusters;
 }