]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EVE/EveDet/AliEveTPCSector3D.cxx
Compilation warnings
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCSector3D.cxx
... / ...
CommitLineData
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#include "AliEveTPCSector3D.h"
11#include <EveDet/AliEveTPCSectorData.h>
12
13#include <TBuffer3D.h>
14#include <TBuffer3DTypes.h>
15#include <TVirtualPad.h>
16#include <TVirtualViewer3D.h>
17
18#include <TStyle.h>
19#include <TColor.h>
20
21
22//______________________________________________________________________________
23//
24// Visualization of TPC raw-data in 3D.
25
26ClassImp(AliEveTPCSector3D)
27
28AliEveTPCSector3D::AliEveTPCSector3D(const Text_t* n, const Text_t* t) :
29 AliEveTPCSectorViz(n, t),
30
31 fBoxSet (n, t),
32 fPointSetArray(n, t),
33 fPointFrac (0.25),
34 fPointSize (3),
35
36 fPointSetOn (0),
37 fPointSetMaxVal (0),
38
39 fDriftVel (1),
40 fZStep (250.0/450)
41{
42 // Constructor.
43
44 fRnrFrame = kFALSE;
45 ComputeBBox();
46}
47
48/******************************************************************************/
49
50void AliEveTPCSector3D::SetRnrFrame(Bool_t rf)
51{
52 // Setter for fRnrFrame.
53
54 if(fRnrFrame != rf) {
55 fRnrFrame = rf;
56 IncRTS();
57 }
58}
59
60/******************************************************************************/
61
62void AliEveTPCSector3D::ComputeBBox()
63{
64 // Compute bounding box containing whole sector.
65
66 const AliEveTPCSectorData::SegmentInfo& iSeg = AliEveTPCSectorData::GetInnSeg();
67 const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg();
68
69 BBoxInit();
70
71 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
72 fBBox[0] = -w;
73 fBBox[1] = w;
74 fBBox[2] = iSeg.GetRLow();
75 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
76 fBBox[4] = 0;
77 fBBox[5] = AliEveTPCSectorData::GetZLength();
78 Float_t* b = fBoxSet.AssertBBox();
79 for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
80
81}
82
83void AliEveTPCSector3D::Paint(Option_t* /*option*/)
84{
85 // Paint object.
86
87 if(fRnrSelf == kFALSE)
88 return;
89
90 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
91
92 // Section kCore
93 buffer.fID = this;
94 buffer.fColor = 1;
95 buffer.fTransparency = 0;
96 fHMTrans.SetBuffer3D(buffer);
97 buffer.SetSectionsValid(TBuffer3D::kCore);
98
99 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
100 if (reqSections == TBuffer3D::kNone) {
101 return;
102 }
103
104 Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported.");
105 return;
106}
107
108/******************************************************************************/
109
110void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter,
111 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
112{
113 // Load data of one padrow. Fill internal boxset and pointset objects.
114
115 Short_t pad, time, val;
116 Float_t x0, z0;
117 Float_t ym = ys + 0.5*ph;
118 Float_t zs = fZStep/fDriftVel;
119
120 while (iter.NextPad())
121 {
122 pad = iter.TEvePad();
123 while (iter.Next())
124 {
125 time = iter.Time();
126 val = iter.Signal();
127
128 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
129 continue;
130
131 if(fPointSetOn && val <= fPointSetMaxVal)
132 {
133 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
134 }
135 else
136 {
137 x0 = xs + pad*pw;
138 z0 = time*zs;
139 fBoxSet.AddBox(x0, ys, z0, pw, ph, zs);
140 fBoxSet.DigitColor(ColorFromArray(val));
141 }
142 }
143 }
144}
145
146void AliEveTPCSector3D::UpdateBoxesAndPoints()
147{
148 // Populate BoxSet and PointSet with digit information.
149
150 // printf("AliEveTPCSector3D update boxes\n");
151
152 fBoxSet.Reset(TEveBoxSet::kBT_AABox, kTRUE, 16384);
153 fPointSetArray.RemoveElements();
154
155 AliEveTPCSectorData* data = GetSectorData();
156 if (data != 0) {
157 Bool_t isOn[3];
158 isOn[0] = fRnrInn;
159 isOn[1] = fRnrOut1;
160 isOn[2] = fRnrOut2;
161
162 SetupColorArray();
163 SetupPointSetArray();
164
165 // Loop over 3 main segments
166 for (Int_t sId = 0; sId <= 2; ++sId) {
167 if(isOn[sId] == kFALSE)
168 continue;
169 const AliEveTPCSectorData::SegmentInfo& sInfo = AliEveTPCSectorData::GetSeg(sId);
170 Float_t sy = sInfo.GetRLow();
171 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
172 AliEveTPCSectorData::RowIterator i = data->MakeRowIterator(row);
173 Float_t sx = -0.5*AliEveTPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
174 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
175 sy += sInfo.GetPadHeight();
176 }
177 }
178
179 fBoxSet.RefitPlex();
180 if (fPointSetOn)
181 fPointSetArray.CloseBins();
182 }
183}
184
185void AliEveTPCSector3D::SetupPointSetArray()
186{
187 // Setup fPointSetArray for current settings.
188
189 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
190 if (nBins > 0) {
191 fPointSetOn = kTRUE;
192 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
193 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
194 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
195 for (Int_t b=0; b<nBins; ++b) {
196 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
197 }
198 } else {
199 fPointSetOn = kFALSE;
200 }
201}