]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/trd_detectors.C
From Basanta: Fix a type, delete TObjArray after loading.
[u/mrichter/AliRoot.git] / EVE / alice-macros / trd_detectors.C
CommitLineData
6983e87a 1//
2// How to steer the basic TRD data containers from a macro.
3//
4// The loading and looping over events is performed by the
5// AliEve mechanism. For a stand alone TRD loop control check
6// the macro "trd_loader.C"
7//
8// Usage:
9// .x trd_detectors.C(sector)
10//
11// Author:
12// Alex Bercuci (A.Bercuci@gsi.de)
13//
66c3c96b 14#ifdef __CINT__
15class TEvePointSet;
16class TEveElement;
17#else
18#include <TEveManager.h>
19#include <TEvePointSet.h>
20#include <EveBase/AliEveEventManager.h>
21
22#include "AliRunLoader.h"
23#include "AliCluster.h"
24#include "AliTRDcluster.h"
25#endif
26
6983e87a 27TEveElementList* trd_detectors(Int_t sector = 2, TEveElement *cont = 0)
66c3c96b 28{
29 // Link data containers
6983e87a 30 AliCDBManager *fCDBManager=AliCDBManager::Instance();
31 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
32 fCDBManager->SetRun(0);
66c3c96b 33
6983e87a 34 TGeoManager *gGeoManager = AliEveEventManager::AssertGeometry();
66c3c96b 35
6983e87a 36 AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
37
38 // define EVE containers
39 TEveElementList *list = new TEveElementList("TRD Detectors");
40
41 AliTRDgeometry *geo = new AliTRDgeometry();
42 //geo->CreateClusterMatrixArray();
43
44 AliEveTRDNode *sm = 0x0, *stk = 0x0;
45 AliEveTRDChamber *chm=0x0;
66c3c96b 46
6983e87a 47 // Link TRD containers
48 TObjArray *clusters = 0x0;
49 rl->LoadRecPoints("TRD");
50 TTree *tR = rl->GetTreeR("TRD", kFALSE);
51 tR->SetBranchAddress("TRDcluster", &clusters);
66c3c96b 52
6983e87a 53 rl->LoadDigits("TRD");
54 TTree *tD = rl->GetTreeD("TRD", kFALSE);
55 AliTRDdigitsManager dm; dm.ReadDigits(tD);
66c3c96b 56
6983e87a 57 for(Int_t i=0; i<tR->GetEntries(); i++) {
58 if (!tR->GetEvent(i)) continue;
66c3c96b 59
6983e87a 60 Int_t idet, ism, istk, ipla, icl=0;
61 AliTRDcluster *c = 0x0;
62 while(!(c = (AliTRDcluster*)clusters->UncheckedAt(icl++))) {;}
63 idet = c->GetDetector();
64 ism = geo->GetSector(idet);
65 istk = geo->GetChamber(idet);
66 ipla = geo->GetPlane(idet);
67 if(ism != sector) continue;
68 if(!sm){
69 list->AddElement(sm = new AliEveTRDNode("SM", ism));
70 sm->SetElementTitle(Form("Supermodule %2d", ism));
66c3c96b 71 }
6983e87a 72 if(!(stk=sm->FindChild(Form("Stack%03d", istk)))){
73 sm->AddElement(stk = new AliEveTRDNode("Stack", istk));
74 stk->SetElementTitle(Form("SM %2d Stack %1d", ism, istk));
75 }
76 stk->AddElement(chm = new AliEveTRDChamber(idet));
77 chm->SetGeometry(geo);
78 chm->LoadClusters(clusters);
79 chm->LoadDigits(&dm);
66c3c96b 80
6983e87a 81 clusters->Clear();
66c3c96b 82 }
6983e87a 83
84 gEve->AddElement(list, cont);
66c3c96b 85 gEve->Redraw3D();
86
6983e87a 87 return list;
66c3c96b 88}