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