]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSector3D.cxx
Remove MCTrackRef class.
[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
14 using namespace Reve;
15 using namespace Alieve;
16
17 //______________________________________________________________________
18 // TPCSector3D
19 //
20
21 ClassImp(TPCSector3D)
22
23 TPCSector3D::TPCSector3D(const Text_t* n, const Text_t* t) :
24   TPCSectorViz(n, t),
25
26   fBoxSet       (n, t),
27   fPointSetArray(n, t),
28   fPointFrac    (0.25),
29   fPointSize    (3),
30
31   fPointSetOn     (0),
32   fPointSetMaxVal (0),
33
34   fDriftVel  (1),
35   fZStep     (250.0/450)
36 {
37   fRnrFrame = kFALSE;
38   ComputeBBox();
39 }
40
41 TPCSector3D::~TPCSector3D()
42 {}
43
44 /**************************************************************************/
45
46 void TPCSector3D::SetRnrFrame(Bool_t rf)
47 {
48   if(fRnrFrame != rf) {
49     fRnrFrame = rf;
50     IncRTS();
51   }
52 }
53
54 /**************************************************************************/
55
56 void TPCSector3D::ComputeBBox()
57 {
58   const TPCSectorData::SegmentInfo&  iSeg = TPCSectorData::GetInnSeg();
59   const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
60
61   BBoxInit();
62
63   Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
64   fBBox[0] = -w;
65   fBBox[1] =  w;
66   fBBox[2] =  iSeg.GetRLow();
67   fBBox[3] =  o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
68   fBBox[4] =  0;
69   fBBox[5] =  TPCSectorData::GetZLength();
70   Float_t* b = fBoxSet.AssertBBox();
71   for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
72
73 }
74
75 void TPCSector3D::Paint(Option_t* /*option*/)
76 {
77   if(fRnrSelf == kFALSE)
78     return;
79
80   TBuffer3D buffer(TBuffer3DTypes::kGeneric);
81
82   // Section kCore
83   buffer.fID           = this;
84   buffer.fColor        = 1;
85   buffer.fTransparency = 0;
86   fHMTrans.SetBuffer3D(buffer);
87   buffer.SetSectionsValid(TBuffer3D::kCore);
88    
89   Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
90   if (reqSections == TBuffer3D::kNone) {
91     return;
92   }
93
94   Error("TPCSector3D::Paint", "only direct OpenGL rendering supported.");
95   return;
96 }
97
98 /**************************************************************************/
99
100 void 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;
104   Float_t x0, z0;
105   Float_t ym = ys + 0.5*ph;
106   Float_t zs = fZStep/fDriftVel;
107
108   while (iter.NextPad())
109   {
110     pad = iter.Pad();
111     while (iter.Next())
112     {
113       time = iter.Time();
114       val  = iter.Signal();
115
116       if(val <= fThreshold || time < fMinTime || time > fMaxTime)
117         continue;
118
119       if(fPointSetOn && val <= fPointSetMaxVal)
120       {
121         fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
122       }
123       else
124       {
125         x0 = xs + pad*pw;
126         z0 = time*zs;
127         fBoxSet.AddBox(x0, ys, z0, pw, ph, zs);
128         fBoxSet.DigitColor(ColorFromArray(val));
129       }
130     }
131   }
132 }
133
134 void TPCSector3D::UpdateBoxes()
135 {
136   // Populate parent class Reve::BoxSet with digit information.
137
138   // printf("TPCSector3D update boxes\n");
139
140   fBoxSet.Reset(BoxSet::BT_AABox, kTRUE, 16384);
141   fPointSetArray.RemoveElements();
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
150     SetupColorArray();
151     SetupPointSetArray();
152
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     }
166
167     fBoxSet.RefitPlex();
168     if(fPointSetOn)
169       fPointSetArray.CloseBins();
170   }
171 }
172
173 void 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);
180     fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
181     for(Int_t b=0; b<nBins; ++b) {
182       fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
183     }
184   } else {
185     fPointSetOn = kFALSE;
186   }
187 }