]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/trd_detectors.C
esd_tracks.C
[u/mrichter/AliRoot.git] / EVE / alice-macros / trd_detectors.C
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 // 
14 #ifdef __CINT__
15 class TEvePointSet;
16 class 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
27 TEveElementList* trd_detectors(Int_t sector = -1, TEveElement *cont = 0)
28 {
29   // Link data containers
30   AliCDBManager *fCDBManager=AliCDBManager::Instance();
31   fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
32   fCDBManager->SetRun(0);
33
34   TGeoManager  *gGeoManager = AliEveEventManager::AssertGeometry();
35
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;
46
47   // Link TRD containers
48   TObjArray *clusters = 0x0;
49   rl->LoadRecPoints("TRD");
50   TTree *tR = rl->GetTreeR("TRD", kFALSE);
51   tR->SetBranchAddress("TRDcluster", &clusters);
52
53   rl->LoadDigits("TRD");
54   TTree *tD = rl->GetTreeD("TRD", kFALSE);
55   AliTRDdigitsManager dm; dm.ReadDigits(tD);
56
57   for(Int_t i=0; i<tR->GetEntries(); i++) {
58     if (!tR->GetEvent(i)) continue;
59     if(!clusters->GetEntries()) continue;
60     Int_t icl=0; AliTRDcluster *c = 0x0;
61     while(!(c = (AliTRDcluster*)clusters->UncheckedAt(icl++))) {;}
62     if(!c) continue;
63
64     Int_t idet, ism, istk, ipla; 
65     idet = c->GetDetector();
66     ism  = geo->GetSector(idet);
67     istk = geo->GetStack(idet);
68     ipla = geo->GetLayer(idet);
69     if(sector>=0 && ism != sector) continue;
70     if(!(sm = list->FindChild(Form("SM%03d", ism)))){ 
71       list->AddElement(sm = new AliEveTRDNode("SM", ism));
72       sm->SetElementTitle(Form("Supermodule %2d", ism));
73     }
74     if(!(stk=sm->FindChild(Form("Stack%03d", istk)))){
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);
82
83     //clusters->Clear();
84   }
85
86   gEve->AddElement(list, cont);
87   gEve->Redraw3D();
88
89   return list;
90 }