]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/emcal_digits.C
Merge changes from branches/dev/EVE. This branch was following development in ROOT...
[u/mrichter/AliRoot.git] / EVE / alice-macros / emcal_digits.C
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 void emcal_digits()
11 {
12   AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
13
14   rl->LoadgAlice();
15   AliEMCAL         * emcal = (AliEMCAL*) rl->GetAliRun()->GetDetector("EMCAL");
16   AliEMCALGeometry * geom  = emcal->GetGeometry();
17
18   rl->LoadDigits("EMCAL");
19   TTree* dt = rl->GetTreeD("EMCAL", kFALSE);
20
21   gGeoManager = gEve->GetGeometry("$REVESYS/alice-data/alice_fullgeo.root");
22   TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
23
24   TGeoBBox* bbbox = (TGeoBBox*) node->GetDaughter(0) ->GetVolume()->GetShape();
25   bbbox->Dump();
26   TGeoBBox* sbbox = (TGeoBBox*) node->GetDaughter(10)->GetVolume()->GetShape();
27   sbbox->Dump();
28
29   TEveElementList* l = new TEveElementList("EMCAL");
30   l->SetTitle("Tooltip");
31   gEve->AddElement(l);
32
33   TEveFrameBox* frame_big = new TEveFrameBox();
34   frame_big->SetAABoxCenterHalfSize(0, 0, 0, bbbox->GetDX(), bbbox->GetDY(), bbbox->GetDZ());
35
36   TEveFrameBox* frame_sml = new TEveFrameBox();
37   frame_sml->SetAABoxCenterHalfSize(0, 0, 0, sbbox->GetDX(), sbbox->GetDY(), sbbox->GetDZ());
38
39   gStyle->SetPalette(1, 0);
40   TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
41   pal->SetLimits(0, 1024);
42
43   TEveQuadSet* smodules[12];
44
45   for (Int_t sm=0; sm<12; ++sm)
46   {
47     TEveQuadSet* q = new TEveQuadSet(Form("SM %d", sm+1));
48     q->SetOwnIds(kTRUE);
49     q->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
50     q->SetDefWidth (geom->GetPhiTileSize());
51     q->SetDefHeight(geom->GetEtaTileSize());
52
53     q->RefMainTrans().SetFrom(*node->GetDaughter(sm)->GetMatrix());
54
55     q->SetFrame(sm < 10 ? frame_big : frame_sml);
56     q->SetPalette(pal);
57
58     gEve->AddElement(q, l);
59     smodules[sm] = q;
60   }
61
62   TClonesArray *digits = 0;
63   dt->SetBranchAddress("EMCAL", &digits);
64   dt->GetEntry(0);
65   Int_t nEnt = digits->GetEntriesFast();
66   AliEMCALDigit * dig;
67
68   Int_t iEvent  = -1 ;
69   Float_t amp   = -1 ;
70   Float_t time  = -1 ;
71   Int_t id      = -1 ;
72   Int_t iSupMod =  0 ;
73   Int_t iTower  =  0 ;
74   Int_t iIphi   =  0 ;
75   Int_t iIeta   =  0 ;
76   Int_t iphi    =  0 ;
77   Int_t ieta    =  0 ;
78   Double_t x, y, z;
79
80   for (Int_t idig = 0; idig < nEnt; ++idig)
81   {
82     dig = static_cast<AliEMCALDigit *>(digits->At(idig));
83
84     if(dig != 0) {
85       id   = dig->GetId() ; //cell (digit) label
86       amp  = dig->GetAmp(); //amplitude in cell (digit)
87       time = dig->GetTime();//time of creation of digit after collision
88
89       cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
90
91       //Geometry methods
92       geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
93       //Gives SuperModule and Tower numbers
94       geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
95                                         iIphi, iIeta,iphi,ieta);
96       //Gives label of cell in eta-phi position per each supermodule
97
98       cout<< "SModule "<<iSupMod<<"; Tower "<<iTower
99           <<"; Eta "<<iIeta<<"; Phi "<<iIphi
100           <<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
101
102       geom->RelPosCellInSModule(id, x, y, z);
103       cout << x <<" "<< y <<" "<< z <<endl;
104
105       TEveQuadSet* q = smodules[iSupMod];
106       q->AddQuad(y, z);
107       q->QuadValue(amp);
108       q->QuadId(dig);
109     } else {
110       cout<<"Digit pointer 0x0"<<endl;
111     }
112   }
113
114   for (Int_t sm = 0; sm < 12; ++sm)
115   {
116     smodules[iSupMod]->RefitPlex();
117   }
118
119   gEve->Redraw3D();
120 }