]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/emcal_digits.C
esd_tracks.C
[u/mrichter/AliRoot.git] / EVE / alice-macros / emcal_digits.C
CommitLineData
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
38aefcea 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
864cb96e 27#include <Riostream.h>
38aefcea 28#endif
16718cdc 29
38fb31ba 30void emcal_digits()
31{
d810d0de 32 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
38fb31ba 33
38fb31ba 34 rl->LoadDigits("EMCAL");
35 TTree* dt = rl->GetTreeD("EMCAL", kFALSE);
38aefcea 36 if (!dt) return;
37
38 AliEveEventManager::AssertGeometry();
38fb31ba 39
38fb31ba 40 TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
41
42 TGeoBBox* bbbox = (TGeoBBox*) node->GetDaughter(0) ->GetVolume()->GetShape();
38fb31ba 43 TGeoBBox* sbbox = (TGeoBBox*) node->GetDaughter(10)->GetVolume()->GetShape();
38fb31ba 44
84aff7a4 45 TEveElementList* l = new TEveElementList("EMCAL");
38fb31ba 46 l->SetTitle("Tooltip");
84aff7a4 47 gEve->AddElement(l);
38fb31ba 48
84aff7a4 49 TEveFrameBox* frame_big = new TEveFrameBox();
38aefcea 50 frame_big->SetFrameColorRGBA(200,200,0,50);
38fb31ba 51 frame_big->SetAABoxCenterHalfSize(0, 0, 0, bbbox->GetDX(), bbbox->GetDY(), bbbox->GetDZ());
52
84aff7a4 53 TEveFrameBox* frame_sml = new TEveFrameBox();
38aefcea 54 frame_sml->SetFrameColorRGBA(200,200,0,50);
38fb31ba 55 frame_sml->SetAABoxCenterHalfSize(0, 0, 0, sbbox->GetDX(), sbbox->GetDY(), sbbox->GetDZ());
56
b58ff8e4 57 gStyle->SetPalette(1, 0);
84aff7a4 58 TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
b58ff8e4 59 pal->SetLimits(0, 1024);
60
84aff7a4 61 TEveQuadSet* smodules[12];
38fb31ba 62
38aefcea 63
64 AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
65 if (!geom) geom = AliEMCALGeometry::GetInstance("","");
66
38fb31ba 67 for (Int_t sm=0; sm<12; ++sm)
68 {
84aff7a4 69 TEveQuadSet* q = new TEveQuadSet(Form("SM %d", sm+1));
38fb31ba 70 q->SetOwnIds(kTRUE);
84aff7a4 71 q->Reset(TEveQuadSet::kQT_RectangleYZFixedDimX, kFALSE, 32);
38fb31ba 72 q->SetDefWidth (geom->GetPhiTileSize());
73 q->SetDefHeight(geom->GetEtaTileSize());
74
a15e6d7d 75 q->RefMainTrans().SetFrom(*node->GetDaughter(sm)->GetMatrix());
38fb31ba 76
77 q->SetFrame(sm < 10 ? frame_big : frame_sml);
b58ff8e4 78 q->SetPalette(pal);
38fb31ba 79
84aff7a4 80 gEve->AddElement(q, l);
38fb31ba 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
38fb31ba 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
84aff7a4 101 for (Int_t idig = 0; idig < nEnt; ++idig)
38fb31ba 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
864cb96e 110 cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
38fb31ba 111
51346b82 112 //Geometry methods
113 geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
38fb31ba 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
864cb96e 119 cout<< "SModule "<<iSupMod<<"; Tower "<<iTower
38fb31ba 120 <<"; Eta "<<iIeta<<"; Phi "<<iIphi
864cb96e 121 <<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
38fb31ba 122
123 geom->RelPosCellInSModule(id, x, y, z);
864cb96e 124 cout << x <<" "<< y <<" "<< z <<endl;
38fb31ba 125
84aff7a4 126 TEveQuadSet* q = smodules[iSupMod];
38fb31ba 127 q->AddQuad(y, z);
38aefcea 128 q->QuadValue(TMath::Nint(amp));
129 q->QuadId(new AliEMCALDigit(*dig));
38fb31ba 130 } else {
864cb96e 131 cout<<"Digit pointer 0x0"<<endl;
38fb31ba 132 }
133 }
134
38aefcea 135 rl->UnloadDigits("EMCAL");
136
137
84aff7a4 138 for (Int_t sm = 0; sm < 12; ++sm)
b58ff8e4 139 {
140 smodules[iSupMod]->RefitPlex();
141 }
142
84aff7a4 143 gEve->Redraw3D();
38fb31ba 144}