]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/TPCSector3D.cxx
First big commit of the mchview program and its accompanying library,
[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
265ecb21 31 fPointSetOn (0),
32 fPointSetMaxVal (0),
33
092578a7 34 fDriftVel (1),
35 fZStep (250.0/450)
36{
8ac84a96 37 fRnrFrame = kFALSE;
092578a7 38 ComputeBBox();
39}
40
41TPCSector3D::~TPCSector3D()
42{}
43
44/**************************************************************************/
45
092578a7 46void TPCSector3D::SetRnrFrame(Bool_t rf)
47{
48 if(fRnrFrame != rf) {
49 fRnrFrame = rf;
50 IncRTS();
51 }
52}
53
54/**************************************************************************/
55
56void TPCSector3D::ComputeBBox()
57{
58 const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg();
59 const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
60
606c4ed7 61 BBoxInit();
32e219c2 62
8ac84a96 63 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
092578a7 64 fBBox[0] = -w;
65 fBBox[1] = w;
66 fBBox[2] = iSeg.GetRLow();
67 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
1a351260 68 fBBox[4] = 0;
69 fBBox[5] = TPCSectorData::GetZLength();
66e0d878 70 Float_t* b = fBoxSet.AssertBBox();
71 for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
72
092578a7 73}
74
8ac84a96 75void TPCSector3D::Paint(Option_t* /*option*/)
092578a7 76{
2caed564 77 if(fRnrSelf == kFALSE)
8ac84a96 78 return;
79
80 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
81
82 // Section kCore
83 buffer.fID = this;
84 buffer.fColor = 1;
85 buffer.fTransparency = 0;
601bca51 86 fHMTrans.SetBuffer3D(buffer);
8ac84a96 87 buffer.SetSectionsValid(TBuffer3D::kCore);
88
89 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
90 if (reqSections == TBuffer3D::kNone) {
91 return;
5987168b 92 }
092578a7 93
601bca51 94 Error("TPCSector3D::Paint", "only direct OpenGL rendering supported.");
8ac84a96 95 return;
092578a7 96}
97
98/**************************************************************************/
99
100void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter,
101 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
102{
103 Short_t pad, time, val;
32e219c2 104 Float_t x0, z0;
9a7ad6a0 105 Float_t ym = ys + 0.5*ph;
9a7ad6a0 106 Float_t zs = fZStep/fDriftVel;
092578a7 107
32e219c2 108 while (iter.NextPad())
109 {
092578a7 110 pad = iter.Pad();
32e219c2 111 while (iter.Next())
112 {
092578a7 113 time = iter.Time();
114 val = iter.Signal();
115
116 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
117 continue;
118
32e219c2 119 if(fPointSetOn && val <= fPointSetMaxVal)
120 {
dcb387f7 121 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
32e219c2 122 }
123 else
124 {
9a7ad6a0 125 x0 = xs + pad*pw;
9a7ad6a0 126 z0 = time*zs;
32e219c2 127 fBoxSet.AddBox(x0, ys, z0, pw, ph, zs);
128 fBoxSet.DigitColor(ColorFromArray(val));
9a7ad6a0 129 }
092578a7 130 }
131 }
132}
133
134void TPCSector3D::UpdateBoxes()
135{
136 // Populate parent class Reve::BoxSet with digit information.
137
138 // printf("TPCSector3D update boxes\n");
139
32e219c2 140 fBoxSet.Reset(BoxSet::BT_AABox, kTRUE, 16384);
dcb387f7 141 fPointSetArray.RemoveElements();
092578a7 142
143 TPCSectorData* data = GetSectorData();
144 if (data != 0) {
145 Bool_t isOn[3];
146 isOn[0] = fRnrInn;
147 isOn[1] = fRnrOut1;
148 isOn[2] = fRnrOut2;
149
8ac84a96 150 SetupColorArray();
9a7ad6a0 151 SetupPointSetArray();
8ac84a96 152
092578a7 153 // Loop over 3 main segments
154 for (Int_t sId = 0; sId <= 2; ++sId) {
155 if(isOn[sId] == kFALSE)
156 continue;
157 const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
158 Float_t sy = sInfo.GetRLow();
159 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
160 TPCSectorData::RowIterator i = data->MakeRowIterator(row);
161 Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
162 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
163 sy += sInfo.GetPadHeight();
164 }
165 }
9a7ad6a0 166
32e219c2 167 fBoxSet.RefitPlex();
9a7ad6a0 168 if(fPointSetOn)
169 fPointSetArray.CloseBins();
170 }
171}
172
173void TPCSector3D::SetupPointSetArray()
174{
175 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
176 if(nBins > 0) {
177 fPointSetOn = kTRUE;
178 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
179 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
dcb387f7 180 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
9a7ad6a0 181 for(Int_t b=0; b<nBins; ++b) {
182 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
183 }
184 } else {
185 fPointSetOn = kFALSE;
092578a7 186 }
092578a7 187}