]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
092578a7 | 3 | |
d810d0de | 4 | /************************************************************************** |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
9 | ||
10 | #include "AliEveTPCSector3D.h" | |
cb4245bb | 11 | #include <EveDet/AliEveTPCSectorData.h> |
092578a7 | 12 | |
a15e6d7d | 13 | #include <TEveTrans.h> |
14 | ||
8ac84a96 | 15 | #include <TBuffer3D.h> |
16 | #include <TBuffer3DTypes.h> | |
17 | #include <TVirtualPad.h> | |
18 | #include <TVirtualViewer3D.h> | |
19 | ||
9a7ad6a0 | 20 | #include <TStyle.h> |
d810d0de | 21 | |
a15e6d7d | 22 | //============================================================================== |
23 | //============================================================================== | |
24 | // AliEveTPCSector3D | |
25 | //============================================================================== | |
092578a7 | 26 | |
57ffa5fb | 27 | //______________________________________________________________________________ |
092578a7 | 28 | // |
a97abca8 | 29 | // Visualization of TPC raw-data in 3D. |
092578a7 | 30 | |
d810d0de | 31 | ClassImp(AliEveTPCSector3D) |
092578a7 | 32 | |
d810d0de | 33 | AliEveTPCSector3D::AliEveTPCSector3D(const Text_t* n, const Text_t* t) : |
34 | AliEveTPCSectorViz(n, t), | |
9a7ad6a0 | 35 | |
36 | fBoxSet (n, t), | |
37 | fPointSetArray(n, t), | |
38 | fPointFrac (0.25), | |
1a351260 | 39 | fPointSize (3), |
092578a7 | 40 | |
265ecb21 | 41 | fPointSetOn (0), |
42 | fPointSetMaxVal (0), | |
43 | ||
1a6da15b | 44 | fDriftVel (1.07), |
969e051c | 45 | fZStep (250.0/900), |
46 | fCutOnEta (kFALSE), | |
47 | fEtaMin (-1.5), | |
48 | fEtaMax (1.5) | |
49 | ||
092578a7 | 50 | { |
a97abca8 | 51 | // Constructor. |
52 | ||
969e051c | 53 | fRnrFrame = kTRUE; |
092578a7 | 54 | ComputeBBox(); |
55 | } | |
56 | ||
57ffa5fb | 57 | /******************************************************************************/ |
092578a7 | 58 | |
d810d0de | 59 | void AliEveTPCSector3D::SetRnrFrame(Bool_t rf) |
092578a7 | 60 | { |
a97abca8 | 61 | // Setter for fRnrFrame. |
62 | ||
092578a7 | 63 | if(fRnrFrame != rf) { |
64 | fRnrFrame = rf; | |
65 | IncRTS(); | |
66 | } | |
67 | } | |
68 | ||
57ffa5fb | 69 | /******************************************************************************/ |
092578a7 | 70 | |
d810d0de | 71 | void AliEveTPCSector3D::ComputeBBox() |
092578a7 | 72 | { |
a97abca8 | 73 | // Compute bounding box containing whole sector. |
74 | ||
d810d0de | 75 | const AliEveTPCSectorData::SegmentInfo& iSeg = AliEveTPCSectorData::GetInnSeg(); |
76 | const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg(); | |
092578a7 | 77 | |
606c4ed7 | 78 | BBoxInit(); |
32e219c2 | 79 | |
8ac84a96 | 80 | Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth(); |
092578a7 | 81 | fBBox[0] = -w; |
82 | fBBox[1] = w; | |
83 | fBBox[2] = iSeg.GetRLow(); | |
84 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
1a351260 | 85 | fBBox[4] = 0; |
d810d0de | 86 | fBBox[5] = AliEveTPCSectorData::GetZLength(); |
66e0d878 | 87 | Float_t* b = fBoxSet.AssertBBox(); |
98277f1f | 88 | for (Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; } |
092578a7 | 89 | } |
90 | ||
d810d0de | 91 | void AliEveTPCSector3D::Paint(Option_t* /*option*/) |
092578a7 | 92 | { |
a97abca8 | 93 | // Paint object. |
94 | ||
2caed564 | 95 | if(fRnrSelf == kFALSE) |
8ac84a96 | 96 | return; |
97 | ||
98 | TBuffer3D buffer(TBuffer3DTypes::kGeneric); | |
99 | ||
969e051c | 100 | SetMainColor(36); |
101 | SetMainTransparency(100); | |
102 | ||
8ac84a96 | 103 | // Section kCore |
104 | buffer.fID = this; | |
68ca2fe7 | 105 | buffer.fColor = GetMainColor(); |
106 | buffer.fTransparency = GetMainTransparency(); | |
a15e6d7d | 107 | if (HasMainTrans()) RefMainTrans().SetBuffer3D(buffer); |
8ac84a96 | 108 | buffer.SetSectionsValid(TBuffer3D::kCore); |
51346b82 | 109 | |
8ac84a96 | 110 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer); |
111 | if (reqSections == TBuffer3D::kNone) { | |
112 | return; | |
5987168b | 113 | } |
092578a7 | 114 | |
d810d0de | 115 | Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported."); |
8ac84a96 | 116 | return; |
092578a7 | 117 | } |
118 | ||
57ffa5fb | 119 | /******************************************************************************/ |
092578a7 | 120 | |
d810d0de | 121 | void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter, |
98277f1f | 122 | Float_t xs, Float_t ys, |
123 | Float_t pw, Float_t ph) | |
092578a7 | 124 | { |
a97abca8 | 125 | // Load data of one padrow. Fill internal boxset and pointset objects. |
126 | ||
092578a7 | 127 | Short_t pad, time, val; |
32e219c2 | 128 | Float_t x0, z0; |
9a7ad6a0 | 129 | Float_t ym = ys + 0.5*ph; |
9a7ad6a0 | 130 | Float_t zs = fZStep/fDriftVel; |
969e051c | 131 | Float_t eta, x1, y1, z1, x, y, z, c, s, zL; |
092578a7 | 132 | |
32e219c2 | 133 | while (iter.NextPad()) |
134 | { | |
84aff7a4 | 135 | pad = iter.TEvePad(); |
32e219c2 | 136 | while (iter.Next()) |
137 | { | |
092578a7 | 138 | time = iter.Time(); |
139 | val = iter.Signal(); | |
140 | ||
98277f1f | 141 | if (val <= fThreshold || time < fMinTime || time > fMaxTime) |
092578a7 | 142 | continue; |
143 | ||
969e051c | 144 | if (fCutOnEta) |
145 | { | |
146 | ||
147 | x1 = xs + (pad+0.5)*pw; | |
148 | y1 = ym; | |
149 | z1 = (time+0.5)*zs; | |
150 | ||
151 | c = TMath::Cos((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::PiOver2()); | |
152 | s = TMath::Sin((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::PiOver2()); | |
153 | zL = AliEveTPCSectorData::GetZLength(); | |
154 | ||
155 | if (fSectorID < 18) | |
156 | { | |
157 | x = -c*x1-s*y1; | |
158 | y = -s*x1+c*y1; | |
159 | z = -z1+zL; | |
160 | } | |
161 | else | |
162 | { | |
163 | x = c*x1+s*y1; | |
164 | y = -s*x1+c*y1; | |
165 | z = z1-zL; | |
166 | } | |
167 | ||
168 | eta = -TMath::Log(TMath::Tan(0.5*TMath::ACos(z/TMath::Sqrt(x*x + y*y + z*z)))); | |
169 | ||
170 | if(!(eta < fEtaMax && eta > fEtaMin) && !(-eta < fEtaMax && -eta > fEtaMin)) | |
171 | continue; | |
172 | ||
173 | } | |
174 | ||
98277f1f | 175 | if (fPointSetOn && val <= fPointSetMaxVal) |
32e219c2 | 176 | { |
dcb387f7 | 177 | fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val); |
32e219c2 | 178 | } |
179 | else | |
180 | { | |
9a7ad6a0 | 181 | x0 = xs + pad*pw; |
9a7ad6a0 | 182 | z0 = time*zs; |
32e219c2 | 183 | fBoxSet.AddBox(x0, ys, z0, pw, ph, zs); |
184 | fBoxSet.DigitColor(ColorFromArray(val)); | |
9a7ad6a0 | 185 | } |
092578a7 | 186 | } |
187 | } | |
188 | } | |
189 | ||
a97abca8 | 190 | void AliEveTPCSector3D::UpdateBoxesAndPoints() |
092578a7 | 191 | { |
a97abca8 | 192 | // Populate BoxSet and PointSet with digit information. |
092578a7 | 193 | |
d810d0de | 194 | // printf("AliEveTPCSector3D update boxes\n"); |
092578a7 | 195 | |
84aff7a4 | 196 | fBoxSet.Reset(TEveBoxSet::kBT_AABox, kTRUE, 16384); |
98277f1f | 197 | // Brutally delete sub-pointsets so that destruction via TEveManager is |
198 | // avoided. This only works because fPointSetArray is never published. | |
199 | for (Int_t i = 0; i < fPointSetArray.GetNBins(); ++i) | |
200 | delete fPointSetArray.GetBin(i); | |
201 | fPointSetArray.RemoveElementsLocal(); | |
092578a7 | 202 | |
d810d0de | 203 | AliEveTPCSectorData* data = GetSectorData(); |
092578a7 | 204 | if (data != 0) { |
205 | Bool_t isOn[3]; | |
206 | isOn[0] = fRnrInn; | |
207 | isOn[1] = fRnrOut1; | |
208 | isOn[2] = fRnrOut2; | |
209 | ||
8ac84a96 | 210 | SetupColorArray(); |
9a7ad6a0 | 211 | SetupPointSetArray(); |
8ac84a96 | 212 | |
092578a7 | 213 | // Loop over 3 main segments |
98277f1f | 214 | for (Int_t sId = 0; sId <= 2; ++sId) |
215 | { | |
216 | if (isOn[sId] == kFALSE) | |
092578a7 | 217 | continue; |
d810d0de | 218 | const AliEveTPCSectorData::SegmentInfo& sInfo = AliEveTPCSectorData::GetSeg(sId); |
092578a7 | 219 | Float_t sy = sInfo.GetRLow(); |
98277f1f | 220 | for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) |
221 | { | |
d810d0de | 222 | AliEveTPCSectorData::RowIterator i = data->MakeRowIterator(row); |
223 | Float_t sx = -0.5*AliEveTPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth(); | |
092578a7 | 224 | LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight()); |
225 | sy += sInfo.GetPadHeight(); | |
226 | } | |
227 | } | |
9a7ad6a0 | 228 | |
32e219c2 | 229 | fBoxSet.RefitPlex(); |
a97abca8 | 230 | if (fPointSetOn) |
9a7ad6a0 | 231 | fPointSetArray.CloseBins(); |
232 | } | |
233 | } | |
234 | ||
d810d0de | 235 | void AliEveTPCSector3D::SetupPointSetArray() |
9a7ad6a0 | 236 | { |
a97abca8 | 237 | // Setup fPointSetArray for current settings. |
238 | ||
239 | Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors()); | |
240 | if (nBins > 0) { | |
9a7ad6a0 | 241 | fPointSetOn = kTRUE; |
242 | fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold)); | |
243 | // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal); | |
a15e6d7d | 244 | fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal); |
a97abca8 | 245 | for (Int_t b=0; b<nBins; ++b) { |
9a7ad6a0 | 246 | fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b)); |
247 | } | |
248 | } else { | |
249 | fPointSetOn = kFALSE; | |
092578a7 | 250 | } |
092578a7 | 251 | } |