]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/TPCSector3D.cxx
Record changes.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSector3D.cxx
CommitLineData
092578a7 1// $Header$
2
3#include "TPCSector3D.h"
4#include <Alieve/TPCSectorData.h>
5
8ac84a96 6#include <TBuffer3D.h>
7#include <TBuffer3DTypes.h>
8#include <TVirtualPad.h>
9#include <TVirtualViewer3D.h>
10
9a7ad6a0 11#include <TStyle.h>
12#include <TColor.h>
13
092578a7 14using namespace Reve;
15using namespace Alieve;
16
17//______________________________________________________________________
18// TPCSector3D
19//
20
21ClassImp(TPCSector3D)
22
23TPCSector3D::TPCSector3D(const Text_t* n, const Text_t* t) :
24 TPCSectorViz(n, t),
9a7ad6a0 25
26 fBoxSet (n, t),
27 fPointSetArray(n, t),
28 fPointFrac (0.25),
1a351260 29 fPointSize (3),
092578a7 30
092578a7 31 fDriftVel (1),
32 fZStep (250.0/450)
33{
8ac84a96 34 fRnrFrame = kFALSE;
092578a7 35 ComputeBBox();
36}
37
38TPCSector3D::~TPCSector3D()
39{}
40
41/**************************************************************************/
42
43UInt_t TPCSector3D::IncRTS()
44{
45 UpdateBoxes();
46 return ++fRTS;
47}
48
49void TPCSector3D::SetRnrFrame(Bool_t rf)
50{
51 if(fRnrFrame != rf) {
52 fRnrFrame = rf;
53 IncRTS();
54 }
55}
56
57/**************************************************************************/
58
59void TPCSector3D::ComputeBBox()
60{
61 const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg();
62 const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
63
606c4ed7 64#if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
092578a7 65 bbox_init();
606c4ed7 66#else
67 BBoxInit();
68#endif
8ac84a96 69 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
092578a7 70 fBBox[0] = -w;
71 fBBox[1] = w;
72 fBBox[2] = iSeg.GetRLow();
73 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
1a351260 74 fBBox[4] = 0;
75 fBBox[5] = TPCSectorData::GetZLength();
66e0d878 76 Float_t* b = fBoxSet.AssertBBox();
77 for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
78
092578a7 79}
80
8ac84a96 81void TPCSector3D::Paint(Option_t* /*option*/)
092578a7 82{
8ac84a96 83 if(fRnrElement == kFALSE)
84 return;
85
86 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
87
88 // Section kCore
89 buffer.fID = this;
90 buffer.fColor = 1;
91 buffer.fTransparency = 0;
92 buffer.fLocalFrame = fTrans;
93 if (fTrans)
94 memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t));
95 buffer.SetSectionsValid(TBuffer3D::kCore);
96
97 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
98 if (reqSections == TBuffer3D::kNone) {
99 return;
5987168b 100 }
092578a7 101
8ac84a96 102 printf("TPCSector3D::Paint only GL supported.\n");
103 return;
092578a7 104}
105
106/**************************************************************************/
107
108void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter,
109 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
110{
111 Short_t pad, time, val;
112 Float_t x0, x1, z0, z1;
9a7ad6a0 113 Float_t ym = ys + 0.5*ph;
092578a7 114 Float_t ye = ys + ph;
9a7ad6a0 115 Float_t zs = fZStep/fDriftVel;
092578a7 116
117 while (iter.NextPad()) {
118 pad = iter.Pad();
119 while (iter.Next()) {
120 time = iter.Time();
121 val = iter.Signal();
122
123 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
124 continue;
125
9a7ad6a0 126 if(fPointSetOn && val <= fPointSetMaxVal) {
127 fPointSetArray.Fill(val, xs + (pad+0.5)*pw, ym, (time+0.5)*zs);
128 } else {
129 fBoxSet.fBoxes.push_back(Reve::Box());
130 ColorFromArray(val, fBoxSet.fBoxes.back().color);
131 x0 = xs + pad*pw;
132 x1 = x0 + pw;
133 z0 = time*zs;
134 z1 = z0 + zs;
135 Float_t* p = fBoxSet.fBoxes.back().vertices;
136 // front
137 p[0] = x0; p[1] = ys; p[2] = z0; p += 3;
138 p[0] = x1; p[1] = ys; p[2] = z0; p += 3;
139 p[0] = x1; p[1] = ye; p[2] = z0; p += 3;
140 p[0] = x0; p[1] = ye; p[2] = z0; p += 3;
141 // back
142 p[0] = x0; p[1] = ys; p[2] = z1; p += 3;
143 p[0] = x1; p[1] = ys; p[2] = z1; p += 3;
144 p[0] = x1; p[1] = ye; p[2] = z1; p += 3;
145 p[0] = x0; p[1] = ye; p[2] = z1;
146 }
092578a7 147 }
148 }
149}
150
151void TPCSector3D::UpdateBoxes()
152{
153 // Populate parent class Reve::BoxSet with digit information.
154
155 // printf("TPCSector3D update boxes\n");
156
157 fBoxSet.ClearSet();
9a7ad6a0 158 fPointSetArray.DeleteBins();
092578a7 159
160 TPCSectorData* data = GetSectorData();
161 if (data != 0) {
162 Bool_t isOn[3];
163 isOn[0] = fRnrInn;
164 isOn[1] = fRnrOut1;
165 isOn[2] = fRnrOut2;
166
8ac84a96 167 SetupColorArray();
9a7ad6a0 168 SetupPointSetArray();
8ac84a96 169
092578a7 170 // Loop over 3 main segments
171 for (Int_t sId = 0; sId <= 2; ++sId) {
172 if(isOn[sId] == kFALSE)
173 continue;
174 const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
175 Float_t sy = sInfo.GetRLow();
176 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
177 TPCSectorData::RowIterator i = data->MakeRowIterator(row);
178 Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
179 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
180 sy += sInfo.GetPadHeight();
181 }
182 }
9a7ad6a0 183
184 if(fPointSetOn)
185 fPointSetArray.CloseBins();
186 }
187}
188
189void TPCSector3D::SetupPointSetArray()
190{
191 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
192 if(nBins > 0) {
193 fPointSetOn = kTRUE;
194 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
195 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
196 fPointSetArray.InitBins(0, "", nBins, fThreshold, fPointSetMaxVal);
197 for(Int_t b=0; b<nBins; ++b) {
198 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
199 }
200 } else {
201 fPointSetOn = kFALSE;
092578a7 202 }
092578a7 203}