3 #include "TPCSector3D.h"
4 #include <Alieve/TPCSectorData.h>
7 #include <TBuffer3DTypes.h>
8 #include <TVirtualPad.h>
9 #include <TVirtualViewer3D.h>
15 using namespace Alieve;
17 //______________________________________________________________________
23 TPCSector3D::TPCSector3D(const Text_t* n, const Text_t* t) :
41 TPCSector3D::~TPCSector3D()
44 /**************************************************************************/
46 void TPCSector3D::SetRnrFrame(Bool_t rf)
54 /**************************************************************************/
56 void TPCSector3D::ComputeBBox()
58 const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg();
59 const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
61 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
66 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
69 fBBox[2] = iSeg.GetRLow();
70 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
72 fBBox[5] = TPCSectorData::GetZLength();
73 Float_t* b = fBoxSet.AssertBBox();
74 for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
78 void TPCSector3D::Paint(Option_t* /*option*/)
80 if(fRnrSelf == kFALSE)
83 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
88 buffer.fTransparency = 0;
89 fHMTrans.SetBuffer3D(buffer);
90 buffer.SetSectionsValid(TBuffer3D::kCore);
92 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
93 if (reqSections == TBuffer3D::kNone) {
97 Error("TPCSector3D::Paint", "only direct OpenGL rendering supported.");
101 /**************************************************************************/
103 void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter,
104 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
106 Short_t pad, time, val;
107 Float_t x0, x1, z0, z1;
108 Float_t ym = ys + 0.5*ph;
109 Float_t ye = ys + ph;
110 Float_t zs = fZStep/fDriftVel;
112 while (iter.NextPad()) {
114 while (iter.Next()) {
118 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
121 if(fPointSetOn && val <= fPointSetMaxVal) {
122 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
124 fBoxSet.fBoxes.push_back(Reve::Box());
125 ColorFromArray(val, fBoxSet.fBoxes.back().color);
130 Float_t* p = fBoxSet.fBoxes.back().vertices;
132 p[0] = x0; p[1] = ys; p[2] = z0; p += 3;
133 p[0] = x1; p[1] = ys; p[2] = z0; p += 3;
134 p[0] = x1; p[1] = ye; p[2] = z0; p += 3;
135 p[0] = x0; p[1] = ye; p[2] = z0; p += 3;
137 p[0] = x0; p[1] = ys; p[2] = z1; p += 3;
138 p[0] = x1; p[1] = ys; p[2] = z1; p += 3;
139 p[0] = x1; p[1] = ye; p[2] = z1; p += 3;
140 p[0] = x0; p[1] = ye; p[2] = z1;
146 void TPCSector3D::UpdateBoxes()
148 // Populate parent class Reve::BoxSet with digit information.
150 // printf("TPCSector3D update boxes\n");
153 fPointSetArray.RemoveElements();
155 TPCSectorData* data = GetSectorData();
163 SetupPointSetArray();
165 // Loop over 3 main segments
166 for (Int_t sId = 0; sId <= 2; ++sId) {
167 if(isOn[sId] == kFALSE)
169 const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
170 Float_t sy = sInfo.GetRLow();
171 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
172 TPCSectorData::RowIterator i = data->MakeRowIterator(row);
173 Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
174 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
175 sy += sInfo.GetPadHeight();
180 fPointSetArray.CloseBins();
184 void TPCSector3D::SetupPointSetArray()
186 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
189 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
190 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
191 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
192 for(Int_t b=0; b<nBins; ++b) {
193 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
196 fPointSetOn = kFALSE;