]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/trd_detectors.C
Clarify cluster loop. Add check for cluster being 0 (seen in online reco-viz).
[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>
9fb2a3ed 21#include <EveDet/AliEveTRDModuleImp.h>
66c3c96b 22
23#include "AliRunLoader.h"
24#include "AliCluster.h"
9fb2a3ed 25#include "TRD/AliTRDcluster.h"
26#include "TRD/AliTRDgeometry.h"
27#include "TRD/AliTRDdigitsManager.h"
66c3c96b 28#endif
29
794d4a46 30TEveElementList* trd_detectors(Int_t sector = -1, TEveElement *cont = 0)
66c3c96b 31{
32 // Link data containers
9fb2a3ed 33 AliEveEventManager::AssertGeometry();
66c3c96b 34
6983e87a 35 AliRunLoader *rl = AliEveEventManager::AssertRunLoader();
36
37 // define EVE containers
38 TEveElementList *list = new TEveElementList("TRD Detectors");
39
6983e87a 40 AliEveTRDNode *sm = 0x0, *stk = 0x0;
41 AliEveTRDChamber *chm=0x0;
66c3c96b 42
6983e87a 43 // Link TRD containers
44 TObjArray *clusters = 0x0;
45 rl->LoadRecPoints("TRD");
46 TTree *tR = rl->GetTreeR("TRD", kFALSE);
289cb8a4 47 if (!tR) return 0;
6983e87a 48 tR->SetBranchAddress("TRDcluster", &clusters);
66c3c96b 49
6983e87a 50 rl->LoadDigits("TRD");
51 TTree *tD = rl->GetTreeD("TRD", kFALSE);
289cb8a4 52 if (!tD) return 0;
6983e87a 53 AliTRDdigitsManager dm; dm.ReadDigits(tD);
66c3c96b 54
289cb8a4 55 AliTRDgeometry *geo = new AliTRDgeometry();
56
6983e87a 57 for(Int_t i=0; i<tR->GetEntries(); i++) {
58 if (!tR->GetEvent(i)) continue;
d4d1b414 59 if(!clusters->GetEntries()) continue;
60 Int_t icl=0; AliTRDcluster *c = 0x0;
6983e87a 61 while(!(c = (AliTRDcluster*)clusters->UncheckedAt(icl++))) {;}
d4d1b414 62 if(!c) continue;
63
64 Int_t idet, ism, istk, ipla;
6983e87a 65 idet = c->GetDetector();
66 ism = geo->GetSector(idet);
794d4a46 67 istk = geo->GetStack(idet);
68 ipla = geo->GetLayer(idet);
69 if(sector>=0 && ism != sector) continue;
9fb2a3ed 70 if(!(sm = (AliEveTRDNode*)list->FindChild(Form("SM%03d", ism)))){
6983e87a 71 list->AddElement(sm = new AliEveTRDNode("SM", ism));
72 sm->SetElementTitle(Form("Supermodule %2d", ism));
66c3c96b 73 }
9fb2a3ed 74 if(!(stk=(AliEveTRDNode*)sm->FindChild(Form("Stack%03d", istk)))){
6983e87a 75 sm->AddElement(stk = new AliEveTRDNode("Stack", istk));
76 stk->SetElementTitle(Form("SM %2d Stack %1d", ism, istk));
77 }
78 stk->AddElement(chm = new AliEveTRDChamber(idet));
79 chm->SetGeometry(geo);
80 chm->LoadClusters(clusters);
81 chm->LoadDigits(&dm);
66c3c96b 82
9b7da201 83 //clusters->Clear();
66c3c96b 84 }
6983e87a 85
9fb2a3ed 86 rl->UnloadDigits("TRD");
87 rl->UnloadRecPoints("TRD");
88
6983e87a 89 gEve->AddElement(list, cont);
66c3c96b 90 gEve->Redraw3D();
91
6983e87a 92 return list;
66c3c96b 93}