]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTPCSector3D.cxx
update extra library list needed for class
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCSector3D.cxx
CommitLineData
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 31ClassImp(AliEveTPCSector3D)
092578a7 32
d810d0de 33AliEveTPCSector3D::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),
99134f85 45 fZStep (250.0/900)
092578a7 46{
a97abca8 47 // Constructor.
48
8ac84a96 49 fRnrFrame = kFALSE;
092578a7 50 ComputeBBox();
51}
52
57ffa5fb 53/******************************************************************************/
092578a7 54
d810d0de 55void 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 67void 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();
98277f1f 84 for (Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
092578a7 85}
86
d810d0de 87void AliEveTPCSector3D::Paint(Option_t* /*option*/)
092578a7 88{
a97abca8 89 // Paint object.
90
2caed564 91 if(fRnrSelf == kFALSE)
8ac84a96 92 return;
93
94 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
95
96 // Section kCore
97 buffer.fID = this;
68ca2fe7 98 buffer.fColor = GetMainColor();
99 buffer.fTransparency = GetMainTransparency();
a15e6d7d 100 if (HasMainTrans()) RefMainTrans().SetBuffer3D(buffer);
8ac84a96 101 buffer.SetSectionsValid(TBuffer3D::kCore);
51346b82 102
8ac84a96 103 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
104 if (reqSections == TBuffer3D::kNone) {
105 return;
5987168b 106 }
092578a7 107
d810d0de 108 Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported.");
8ac84a96 109 return;
092578a7 110}
111
57ffa5fb 112/******************************************************************************/
092578a7 113
d810d0de 114void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter,
98277f1f 115 Float_t xs, Float_t ys,
116 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
98277f1f 133 if (val <= fThreshold || time < fMinTime || time > fMaxTime)
092578a7 134 continue;
135
98277f1f 136 if (fPointSetOn && val <= fPointSetMaxVal)
32e219c2 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 151void 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);
98277f1f 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();
092578a7 163
d810d0de 164 AliEveTPCSectorData* data = GetSectorData();
092578a7 165 if (data != 0) {
166 Bool_t isOn[3];
167 isOn[0] = fRnrInn;
168 isOn[1] = fRnrOut1;
169 isOn[2] = fRnrOut2;
170
8ac84a96 171 SetupColorArray();
9a7ad6a0 172 SetupPointSetArray();
8ac84a96 173
092578a7 174 // Loop over 3 main segments
98277f1f 175 for (Int_t sId = 0; sId <= 2; ++sId)
176 {
177 if (isOn[sId] == kFALSE)
092578a7 178 continue;
d810d0de 179 const AliEveTPCSectorData::SegmentInfo& sInfo = AliEveTPCSectorData::GetSeg(sId);
092578a7 180 Float_t sy = sInfo.GetRLow();
98277f1f 181 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row)
182 {
d810d0de 183 AliEveTPCSectorData::RowIterator i = data->MakeRowIterator(row);
184 Float_t sx = -0.5*AliEveTPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
092578a7 185 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
186 sy += sInfo.GetPadHeight();
187 }
188 }
9a7ad6a0 189
32e219c2 190 fBoxSet.RefitPlex();
a97abca8 191 if (fPointSetOn)
9a7ad6a0 192 fPointSetArray.CloseBins();
193 }
194}
195
d810d0de 196void AliEveTPCSector3D::SetupPointSetArray()
9a7ad6a0 197{
a97abca8 198 // Setup fPointSetArray for current settings.
199
200 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
201 if (nBins > 0) {
9a7ad6a0 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);
a15e6d7d 205 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal);
a97abca8 206 for (Int_t b=0; b<nBins; ++b) {
9a7ad6a0 207 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
208 }
209 } else {
210 fPointSetOn = kFALSE;
092578a7 211 }
092578a7 212}