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 <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),
57 /******************************************************************************/
59 void AliEveTPCSector3D::SetRnrFrame(Bool_t rf)
61 // Setter for fRnrFrame.
69 /******************************************************************************/
71 void AliEveTPCSector3D::ComputeBBox()
73 // Compute bounding box containing whole sector.
75 const AliEveTPCSectorData::SegmentInfo& iSeg = AliEveTPCSectorData::GetInnSeg();
76 const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg();
80 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
83 fBBox[2] = iSeg.GetRLow();
84 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
86 fBBox[5] = AliEveTPCSectorData::GetZLength();
87 Float_t* b = fBoxSet.AssertBBox();
88 for (Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
91 void AliEveTPCSector3D::Paint(Option_t* /*option*/)
95 if(fRnrSelf == kFALSE)
98 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
101 SetMainTransparency(100);
105 buffer.fColor = GetMainColor();
106 buffer.fTransparency = GetMainTransparency();
107 if (HasMainTrans()) RefMainTrans().SetBuffer3D(buffer);
108 buffer.SetSectionsValid(TBuffer3D::kCore);
110 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
111 if (reqSections == TBuffer3D::kNone) {
115 Error("AliEveTPCSector3D::Paint", "only direct OpenGL rendering supported.");
119 /******************************************************************************/
121 void AliEveTPCSector3D::LoadPadrow(AliEveTPCSectorData::RowIterator& iter,
122 Float_t xs, Float_t ys,
123 Float_t pw, Float_t ph)
125 // Load data of one padrow. Fill internal boxset and pointset objects.
127 Short_t pad, time, val;
129 Float_t ym = ys + 0.5*ph;
130 Float_t zs = fZStep/fDriftVel;
131 Float_t eta, x1, y1, z1, x, y, z, c, s, zL;
133 while (iter.NextPad())
135 pad = iter.TEvePad();
141 if (val <= fThreshold || time < fMinTime || time > fMaxTime)
147 x1 = xs + (pad+0.5)*pw;
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();
168 eta = -TMath::Log(TMath::Tan(0.5*TMath::ACos(z/TMath::Sqrt(x*x + y*y + z*z))));
170 if(!(eta < fEtaMax && eta > fEtaMin) && !(-eta < fEtaMax && -eta > fEtaMin))
175 if (fPointSetOn && val <= fPointSetMaxVal)
177 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
183 fBoxSet.AddBox(x0, ys, z0, pw, ph, zs);
184 fBoxSet.DigitColor(ColorFromArray(val));
190 void AliEveTPCSector3D::UpdateBoxesAndPoints()
192 // Populate BoxSet and PointSet with digit information.
194 // printf("AliEveTPCSector3D update boxes\n");
196 fBoxSet.Reset(TEveBoxSet::kBT_AABox, kTRUE, 16384);
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();
203 AliEveTPCSectorData* data = GetSectorData();
211 SetupPointSetArray();
213 // Loop over 3 main segments
214 for (Int_t sId = 0; sId <= 2; ++sId)
216 if (isOn[sId] == kFALSE)
218 const AliEveTPCSectorData::SegmentInfo& sInfo = AliEveTPCSectorData::GetSeg(sId);
219 Float_t sy = sInfo.GetRLow();
220 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row)
222 AliEveTPCSectorData::RowIterator i = data->MakeRowIterator(row);
223 Float_t sx = -0.5*AliEveTPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
224 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
225 sy += sInfo.GetPadHeight();
231 fPointSetArray.CloseBins();
235 void AliEveTPCSector3D::SetupPointSetArray()
237 // Setup fPointSetArray for current settings.
239 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
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);
244 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal);
245 for (Int_t b=0; b<nBins; ++b) {
246 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
249 fPointSetOn = kFALSE;