Add example of how to assign lines to a module.
[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
27#include <iostream>
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;
599519ff 82
83 // Add line
84 /*
85 TEveLine *ll = new TEveLine("Test");
86 ll->SetMainColor(kRed);
87 ll->SetLineWidth(2);
88
89 ll->SetNextPoint(0, -20, -20);
90 ll->SetNextPoint(0, 20, -20);
91 ll->SetNextPoint(0, 20, 20);
92 ll->SetNextPoint(0, -20, 20);
93 ll->SetNextPoint(0, -20, -20);
94 ll->RefMainTrans() = q->RefMainTrans();
95
96 q->AddElement(ll);
97 */
38fb31ba 98 }
99
100 TClonesArray *digits = 0;
101 dt->SetBranchAddress("EMCAL", &digits);
102 dt->GetEntry(0);
103 Int_t nEnt = digits->GetEntriesFast();
104 AliEMCALDigit * dig;
105
38fb31ba 106 Float_t amp = -1 ;
107 Float_t time = -1 ;
108 Int_t id = -1 ;
109 Int_t iSupMod = 0 ;
110 Int_t iTower = 0 ;
111 Int_t iIphi = 0 ;
112 Int_t iIeta = 0 ;
113 Int_t iphi = 0 ;
114 Int_t ieta = 0 ;
115 Double_t x, y, z;
116
84aff7a4 117 for (Int_t idig = 0; idig < nEnt; ++idig)
38fb31ba 118 {
119 dig = static_cast<AliEMCALDigit *>(digits->At(idig));
120
121 if(dig != 0) {
122 id = dig->GetId() ; //cell (digit) label
123 amp = dig->GetAmp(); //amplitude in cell (digit)
124 time = dig->GetTime();//time of creation of digit after collision
125
38aefcea 126 std::cout<<"Cell ID "<<id<<" Amp "<<amp<<std::endl;//" time "<<time<<endl;
38fb31ba 127
51346b82 128 //Geometry methods
129 geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
38fb31ba 130 //Gives SuperModule and Tower numbers
131 geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
132 iIphi, iIeta,iphi,ieta);
133 //Gives label of cell in eta-phi position per each supermodule
134
38aefcea 135 std::cout<< "SModule "<<iSupMod<<"; Tower "<<iTower
38fb31ba 136 <<"; Eta "<<iIeta<<"; Phi "<<iIphi
38aefcea 137 <<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<std::endl;
38fb31ba 138
139 geom->RelPosCellInSModule(id, x, y, z);
38aefcea 140 std::cout << x <<" "<< y <<" "<< z <<std::endl;
38fb31ba 141
84aff7a4 142 TEveQuadSet* q = smodules[iSupMod];
38fb31ba 143 q->AddQuad(y, z);
38aefcea 144 q->QuadValue(TMath::Nint(amp));
145 q->QuadId(new AliEMCALDigit(*dig));
38fb31ba 146 } else {
38aefcea 147 std::cout<<"Digit pointer 0x0"<<std::endl;
38fb31ba 148 }
149 }
150
38aefcea 151 rl->UnloadDigits("EMCAL");
152
153
84aff7a4 154 for (Int_t sm = 0; sm < 12; ++sm)
b58ff8e4 155 {
156 smodules[iSupMod]->RefitPlex();
157 }
158
84aff7a4 159 gEve->Redraw3D();
38fb31ba 160}