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