2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 #include "AliEveTPCSector3D.h"
11 #include <EveDet/AliEveTPCSectorData.h>
13 #include <TEveTrans.h>
15 #include <TBuffer3D.h>
16 #include <TBuffer3DTypes.h>
17 #include <TVirtualPad.h>
18 #include <TVirtualViewer3D.h>
22 //==============================================================================
23 //==============================================================================
25 //==============================================================================
27 //______________________________________________________________________________
29 // Visualization of TPC raw-data in 3D.
31 ClassImp(AliEveTPCSector3D)
33 AliEveTPCSector3D::AliEveTPCSector3D(const Text_t* n, const Text_t* t) :
34 AliEveTPCSectorViz(n, t),
53 /******************************************************************************/
55 void AliEveTPCSector3D::SetRnrFrame(Bool_t rf)
57 // Setter for fRnrFrame.
65 /******************************************************************************/
67 void AliEveTPCSector3D::ComputeBBox()
69 // Compute bounding box containing whole sector.
71 const AliEveTPCSectorData::SegmentInfo& iSeg = AliEveTPCSectorData::GetInnSeg();
72 const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg();
76 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
79 fBBox[2] = iSeg.GetRLow();
80 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
82 fBBox[5] = AliEveTPCSectorData::GetZLength();
83 Float_t* b = fBoxSet.AssertBBox();
84 for (Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
87 void AliEveTPCSector3D::Paint(Option_t* /*option*/)
91 if(fRnrSelf == kFALSE)
94 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
99 buffer.fTransparency = 0;
100 if (HasMainTrans()) RefMainTrans().SetBuffer3D(buffer);
101 buffer.SetSectionsValid(TBuffer3D::kCore);
103 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
104 if (reqSections == TBuffer3D::kNone) {
108 Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported.");
112 /******************************************************************************/
114 void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter,
115 Float_t xs, Float_t ys,
116 Float_t pw, Float_t ph)
118 // Load data of one padrow. Fill internal boxset and pointset objects.
120 Short_t pad, time, val;
122 Float_t ym = ys + 0.5*ph;
123 Float_t zs = fZStep/fDriftVel;
125 while (iter.NextPad())
127 pad = iter.TEvePad();
133 if (val <= fThreshold || time < fMinTime || time > fMaxTime)
136 if (fPointSetOn && val <= fPointSetMaxVal)
138 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
144 fBoxSet.AddBox(x0, ys, z0, pw, ph, zs);
145 fBoxSet.DigitColor(ColorFromArray(val));
151 void AliEveTPCSector3D::UpdateBoxesAndPoints()
153 // Populate BoxSet and PointSet with digit information.
155 // printf("AliEveTPCSector3D update boxes\n");
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();
164 AliEveTPCSectorData* data = GetSectorData();
172 SetupPointSetArray();
174 // Loop over 3 main segments
175 for (Int_t sId = 0; sId <= 2; ++sId)
177 if (isOn[sId] == kFALSE)
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)
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();
192 fPointSetArray.CloseBins();
196 void AliEveTPCSector3D::SetupPointSetArray()
198 // Setup fPointSetArray for current settings.
200 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
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));
210 fPointSetOn = kFALSE;