]>
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 | ||
092578a7 | 44 | fDriftVel (1), |
45 | fZStep (250.0/450) | |
46 | { | |
a97abca8 | 47 | // Constructor. |
48 | ||
8ac84a96 | 49 | fRnrFrame = kFALSE; |
092578a7 | 50 | ComputeBBox(); |
51 | } | |
52 | ||
57ffa5fb | 53 | /******************************************************************************/ |
092578a7 | 54 | |
d810d0de | 55 | void AliEveTPCSector3D::SetRnrFrame(Bool_t rf) |
092578a7 | 56 | { |
a97abca8 | 57 | // Setter for fRnrFrame. |
58 | ||
092578a7 | 59 | if(fRnrFrame != rf) { |
60 | fRnrFrame = rf; | |
61 | IncRTS(); | |
62 | } | |
63 | } | |
64 | ||
57ffa5fb | 65 | /******************************************************************************/ |
092578a7 | 66 | |
d810d0de | 67 | void AliEveTPCSector3D::ComputeBBox() |
092578a7 | 68 | { |
a97abca8 | 69 | // Compute bounding box containing whole sector. |
70 | ||
d810d0de | 71 | const AliEveTPCSectorData::SegmentInfo& iSeg = AliEveTPCSectorData::GetInnSeg(); |
72 | const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg(); | |
092578a7 | 73 | |
606c4ed7 | 74 | BBoxInit(); |
32e219c2 | 75 | |
8ac84a96 | 76 | Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth(); |
092578a7 | 77 | fBBox[0] = -w; |
78 | fBBox[1] = w; | |
79 | fBBox[2] = iSeg.GetRLow(); | |
80 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
1a351260 | 81 | fBBox[4] = 0; |
d810d0de | 82 | fBBox[5] = AliEveTPCSectorData::GetZLength(); |
66e0d878 | 83 | Float_t* b = fBoxSet.AssertBBox(); |
84 | for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; } | |
85 | ||
092578a7 | 86 | } |
87 | ||
d810d0de | 88 | void AliEveTPCSector3D::Paint(Option_t* /*option*/) |
092578a7 | 89 | { |
a97abca8 | 90 | // Paint object. |
91 | ||
2caed564 | 92 | if(fRnrSelf == kFALSE) |
8ac84a96 | 93 | return; |
94 | ||
95 | TBuffer3D buffer(TBuffer3DTypes::kGeneric); | |
96 | ||
97 | // Section kCore | |
98 | buffer.fID = this; | |
99 | buffer.fColor = 1; | |
100 | buffer.fTransparency = 0; | |
a15e6d7d | 101 | if (HasMainTrans()) RefMainTrans().SetBuffer3D(buffer); |
8ac84a96 | 102 | buffer.SetSectionsValid(TBuffer3D::kCore); |
51346b82 | 103 | |
8ac84a96 | 104 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer); |
105 | if (reqSections == TBuffer3D::kNone) { | |
106 | return; | |
5987168b | 107 | } |
092578a7 | 108 | |
d810d0de | 109 | Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported."); |
8ac84a96 | 110 | return; |
092578a7 | 111 | } |
112 | ||
57ffa5fb | 113 | /******************************************************************************/ |
092578a7 | 114 | |
d810d0de | 115 | void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter, |
51346b82 | 116 | Float_t xs, Float_t ys, Float_t pw, Float_t ph) |
092578a7 | 117 | { |
a97abca8 | 118 | // Load data of one padrow. Fill internal boxset and pointset objects. |
119 | ||
092578a7 | 120 | Short_t pad, time, val; |
32e219c2 | 121 | Float_t x0, z0; |
9a7ad6a0 | 122 | Float_t ym = ys + 0.5*ph; |
9a7ad6a0 | 123 | Float_t zs = fZStep/fDriftVel; |
092578a7 | 124 | |
32e219c2 | 125 | while (iter.NextPad()) |
126 | { | |
84aff7a4 | 127 | pad = iter.TEvePad(); |
32e219c2 | 128 | while (iter.Next()) |
129 | { | |
092578a7 | 130 | time = iter.Time(); |
131 | val = iter.Signal(); | |
132 | ||
133 | if(val <= fThreshold || time < fMinTime || time > fMaxTime) | |
134 | continue; | |
135 | ||
32e219c2 | 136 | if(fPointSetOn && val <= fPointSetMaxVal) |
137 | { | |
dcb387f7 | 138 | fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val); |
32e219c2 | 139 | } |
140 | else | |
141 | { | |
9a7ad6a0 | 142 | x0 = xs + pad*pw; |
9a7ad6a0 | 143 | z0 = time*zs; |
32e219c2 | 144 | fBoxSet.AddBox(x0, ys, z0, pw, ph, zs); |
145 | fBoxSet.DigitColor(ColorFromArray(val)); | |
9a7ad6a0 | 146 | } |
092578a7 | 147 | } |
148 | } | |
149 | } | |
150 | ||
a97abca8 | 151 | void AliEveTPCSector3D::UpdateBoxesAndPoints() |
092578a7 | 152 | { |
a97abca8 | 153 | // Populate BoxSet and PointSet with digit information. |
092578a7 | 154 | |
d810d0de | 155 | // printf("AliEveTPCSector3D update boxes\n"); |
092578a7 | 156 | |
84aff7a4 | 157 | fBoxSet.Reset(TEveBoxSet::kBT_AABox, kTRUE, 16384); |
dcb387f7 | 158 | fPointSetArray.RemoveElements(); |
092578a7 | 159 | |
d810d0de | 160 | AliEveTPCSectorData* data = GetSectorData(); |
092578a7 | 161 | if (data != 0) { |
162 | Bool_t isOn[3]; | |
163 | isOn[0] = fRnrInn; | |
164 | isOn[1] = fRnrOut1; | |
165 | isOn[2] = fRnrOut2; | |
166 | ||
8ac84a96 | 167 | SetupColorArray(); |
9a7ad6a0 | 168 | SetupPointSetArray(); |
8ac84a96 | 169 | |
092578a7 | 170 | // Loop over 3 main segments |
171 | for (Int_t sId = 0; sId <= 2; ++sId) { | |
172 | if(isOn[sId] == kFALSE) | |
173 | continue; | |
d810d0de | 174 | const AliEveTPCSectorData::SegmentInfo& sInfo = AliEveTPCSectorData::GetSeg(sId); |
092578a7 | 175 | Float_t sy = sInfo.GetRLow(); |
176 | for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) { | |
d810d0de | 177 | AliEveTPCSectorData::RowIterator i = data->MakeRowIterator(row); |
178 | Float_t sx = -0.5*AliEveTPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth(); | |
092578a7 | 179 | LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight()); |
180 | sy += sInfo.GetPadHeight(); | |
181 | } | |
182 | } | |
9a7ad6a0 | 183 | |
32e219c2 | 184 | fBoxSet.RefitPlex(); |
a97abca8 | 185 | if (fPointSetOn) |
9a7ad6a0 | 186 | fPointSetArray.CloseBins(); |
187 | } | |
188 | } | |
189 | ||
d810d0de | 190 | void AliEveTPCSector3D::SetupPointSetArray() |
9a7ad6a0 | 191 | { |
a97abca8 | 192 | // Setup fPointSetArray for current settings. |
193 | ||
194 | Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors()); | |
195 | if (nBins > 0) { | |
9a7ad6a0 | 196 | fPointSetOn = kTRUE; |
197 | fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold)); | |
198 | // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal); | |
a15e6d7d | 199 | fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal); |
a97abca8 | 200 | for (Int_t b=0; b<nBins; ++b) { |
9a7ad6a0 | 201 | fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b)); |
202 | } | |
203 | } else { | |
204 | fPointSetOn = kFALSE; | |
092578a7 | 205 | } |
092578a7 | 206 | } |