]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/muon_clusters.C
coverity fix for 18249
[u/mrichter/AliRoot.git] / EVE / alice-macros / muon_clusters.C
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
6  * full copyright notice.                                                 *
7  **************************************************************************/
8
9 /// \ingroup evemacros
10 /// \file muon_clusters.C
11 /// \brief Macro to visualise clusters from MUON spectrometer 
12 /// (both tracker and trigger).
13 ///
14 /// Use muon_clusters() in order to run it.
15 ///
16 /// Needs that alieve_init() is already called.
17 ///
18 /// \author P. Pillot, L. Aphecetche; Subatech
19
20 #ifndef __CINT__
21
22 #include "AliMUONVCluster.h"
23 #include "AliMUONVClusterStore.h"
24
25 #include "AliRunLoader.h"
26
27 #include "EveBase/AliEveEventManager.h"
28
29 #include <TEveManager.h>
30 #include <TEvePointSet.h>
31
32 #include <TTree.h>
33 #include <Riostream.h>
34
35 #endif
36 class TIter;
37 class TEvePointSet;
38
39 //______________________________________________________________________________
40 void add_muon_clusters(TIter* next, TEvePointSet* clusterList)
41 {
42   // loop over clusters and produce corresponding graphic objects
43   AliMUONVCluster* cluster;
44   while ( ( cluster = static_cast<AliMUONVCluster*>((*next)()) ) ) 
45   {  
46     clusterList->SetNextPoint(cluster->GetX(),cluster->GetY(),cluster->GetZ());
47   }
48 }
49
50 //______________________________________________________________________________
51 void muon_clusters()
52 {
53   // load clusters
54   AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
55   rl->LoadRecPoints("MUON");
56   TTree* ct = rl->GetTreeR("MUON",kFALSE);
57   if (!ct) return;
58   AliMUONVClusterStore* clusterStore = AliMUONVClusterStore::Create(*ct);
59   clusterStore->Clear();
60   clusterStore->Connect(*ct,kFALSE);
61   ct->GetEvent(0);
62   rl->UnloadRecPoints("MUON");
63   
64   if (clusterStore->GetSize() == 0 && !gEve->GetKeepEmptyCont()) {
65     delete clusterStore;
66     return;
67   }
68   
69   // cluster container
70   TEvePointSet* clusterList = new TEvePointSet(10000);
71   clusterList->SetName("MUON Clusters");
72   clusterList->SetTitle(Form("N=%d",clusterStore->GetSize()));
73   clusterList->SetPickable(kFALSE);
74   clusterList->SetMarkerStyle(20);
75   clusterList->SetMarkerColor(kCyan);
76   clusterList->SetMarkerSize(1.);
77   
78   // add cluster to the container
79   TIter next(clusterStore->CreateIterator());
80   add_muon_clusters(&next, clusterList);
81   delete clusterStore;
82   
83   // add graphic containers
84   gEve->DisableRedraw();
85   gEve->AddElement(clusterList);
86   gEve->EnableRedraw();
87   gEve->Redraw3D();
88 }