]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/emcal_digits.C
first version of list analyser steering macro (Ben)
[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 #ifndef __CINT__
10
11 #include <TEveManager.h>
12 #include <TEveQuadSet.h>
13 #include <TGeoNode.h>
14 #include <TGeoBBox.h>
15 #include <TGeoManager.h>
16 #include <TStyle.h>
17 #include <TEveTrans.h>
18 #include <TClonesArray.h>
19
20 #include <EveBase/AliEveEventManager.h>
21
22 #include <AliRunLoader.h>
23 #include <AliCluster.h>
24 #include <EMCAL/AliEMCALGeometry.h>
25 #include <EMCAL/AliEMCALDigit.h>
26
27 #include <Riostream.h>
28 #endif
29
30 void emcal_digits()
31 {
32   AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
33
34   rl->LoadDigits("EMCAL");
35   TTree* dt = rl->GetTreeD("EMCAL", kFALSE);
36   if (!dt) return;
37
38   AliEveEventManager::AssertGeometry();
39
40   TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
41
42   TGeoBBox* bbbox = (TGeoBBox*) node->GetDaughter(0) ->GetVolume()->GetShape();
43   TGeoBBox* sbbox = (TGeoBBox*) node->GetDaughter(10)->GetVolume()->GetShape();
44
45   TEveElementList* l = new TEveElementList("EMCAL");
46   l->SetTitle("Tooltip");
47   gEve->AddElement(l);
48
49   TEveFrameBox* frame_big = new TEveFrameBox();
50   frame_big->SetFrameColorRGBA(200,200,0,50);
51   frame_big->SetAABoxCenterHalfSize(0, 0, 0, bbbox->GetDX(), bbbox->GetDY(), bbbox->GetDZ());
52
53   TEveFrameBox* frame_sml = new TEveFrameBox();
54   frame_sml->SetFrameColorRGBA(200,200,0,50);
55   frame_sml->SetAABoxCenterHalfSize(0, 0, 0, sbbox->GetDX(), sbbox->GetDY(), sbbox->GetDZ());
56
57   gStyle->SetPalette(1, 0);
58   TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
59   pal->SetLimits(0, 1024);
60
61   TEveQuadSet* smodules[12];
62
63
64   AliEMCALGeometry * geom  = AliEMCALGeometry::GetInstance();  
65   if (!geom) geom = AliEMCALGeometry::GetInstance("","");
66
67   for (Int_t sm=0; sm<12; ++sm)
68   {
69     TEveQuadSet* q = new TEveQuadSet(Form("SM %d", sm+1));
70     q->SetOwnIds(kTRUE);
71     q->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
72     q->SetDefWidth (geom->GetPhiTileSize());
73     q->SetDefHeight(geom->GetEtaTileSize());
74
75     q->RefMainTrans().SetFrom(*node->GetDaughter(sm)->GetMatrix());
76
77     q->SetFrame(sm < 10 ? frame_big : frame_sml);
78     q->SetPalette(pal);
79
80     gEve->AddElement(q, l);
81     smodules[sm] = q;
82   }
83
84   TClonesArray *digits = 0;
85   dt->SetBranchAddress("EMCAL", &digits);
86   dt->GetEntry(0);
87   Int_t nEnt = digits->GetEntriesFast();
88   AliEMCALDigit * dig;
89
90   Float_t amp   = -1 ;
91   Float_t time  = -1 ;
92   Int_t id      = -1 ;
93   Int_t iSupMod =  0 ;
94   Int_t iTower  =  0 ;
95   Int_t iIphi   =  0 ;
96   Int_t iIeta   =  0 ;
97   Int_t iphi    =  0 ;
98   Int_t ieta    =  0 ;
99   Double_t x, y, z;
100
101   for (Int_t idig = 0; idig < nEnt; ++idig)
102   {
103     dig = static_cast<AliEMCALDigit *>(digits->At(idig));
104
105     if(dig != 0) {
106       id   = dig->GetId() ; //cell (digit) label
107       amp  = dig->GetAmp(); //amplitude in cell (digit)
108       time = dig->GetTime();//time of creation of digit after collision
109
110       cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
111
112       //Geometry methods
113       geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
114       //Gives SuperModule and Tower numbers
115       geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
116                                         iIphi, iIeta,iphi,ieta);
117       //Gives label of cell in eta-phi position per each supermodule
118
119       cout<< "SModule "<<iSupMod<<"; Tower "<<iTower
120           <<"; Eta "<<iIeta<<"; Phi "<<iIphi
121           <<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
122
123       geom->RelPosCellInSModule(id, x, y, z);
124       cout << x <<" "<< y <<" "<< z <<endl;
125
126       TEveQuadSet* q = smodules[iSupMod];
127       q->AddQuad(y, z);
128       q->QuadValue(TMath::Nint(amp));
129       q->QuadId(new AliEMCALDigit(*dig));
130     } else {
131       cout<<"Digit pointer 0x0"<<endl;
132     }
133   }
134
135   rl->UnloadDigits("EMCAL");
136
137
138   for (Int_t sm = 0; sm < 12; ++sm)
139   {
140     smodules[iSupMod]->RefitPlex();
141   }
142
143   gEve->Redraw3D();
144 }