]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/trd_detectors.C
From Basanta: I have modified the AliPMDRawStream file which needs little modification
[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 = 2, 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
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));
71     }
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);
80
81     clusters->Clear();
82   }
83
84   gEve->AddElement(list, cont);
85   gEve->Redraw3D();
86
87   return list;
88 }