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(fRnrElement == kFALSE)
83 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
88 buffer.fTransparency = 0;
89 buffer.fLocalFrame = fTrans;
91 memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t));
92 buffer.SetSectionsValid(TBuffer3D::kCore);
94 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
95 if (reqSections == TBuffer3D::kNone) {
99 printf("TPCSector3D::Paint only GL supported.\n");
103 /**************************************************************************/
105 void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter,
106 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
108 Short_t pad, time, val;
109 Float_t x0, x1, z0, z1;
110 Float_t ym = ys + 0.5*ph;
111 Float_t ye = ys + ph;
112 Float_t zs = fZStep/fDriftVel;
114 while (iter.NextPad()) {
116 while (iter.Next()) {
120 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
123 if(fPointSetOn && val <= fPointSetMaxVal) {
124 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
126 fBoxSet.fBoxes.push_back(Reve::Box());
127 ColorFromArray(val, fBoxSet.fBoxes.back().color);
132 Float_t* p = fBoxSet.fBoxes.back().vertices;
134 p[0] = x0; p[1] = ys; p[2] = z0; p += 3;
135 p[0] = x1; p[1] = ys; p[2] = z0; p += 3;
136 p[0] = x1; p[1] = ye; p[2] = z0; p += 3;
137 p[0] = x0; p[1] = ye; p[2] = z0; p += 3;
139 p[0] = x0; p[1] = ys; p[2] = z1; p += 3;
140 p[0] = x1; p[1] = ys; p[2] = z1; p += 3;
141 p[0] = x1; p[1] = ye; p[2] = z1; p += 3;
142 p[0] = x0; p[1] = ye; p[2] = z1;
148 void TPCSector3D::UpdateBoxes()
150 // Populate parent class Reve::BoxSet with digit information.
152 // printf("TPCSector3D update boxes\n");
155 fPointSetArray.RemoveElements();
157 TPCSectorData* data = GetSectorData();
165 SetupPointSetArray();
167 // Loop over 3 main segments
168 for (Int_t sId = 0; sId <= 2; ++sId) {
169 if(isOn[sId] == kFALSE)
171 const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
172 Float_t sy = sInfo.GetRLow();
173 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
174 TPCSectorData::RowIterator i = data->MakeRowIterator(row);
175 Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
176 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
177 sy += sInfo.GetPadHeight();
182 fPointSetArray.CloseBins();
186 void TPCSector3D::SetupPointSetArray()
188 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
191 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
192 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
193 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
194 for(Int_t b=0; b<nBins; ++b) {
195 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
198 fPointSetOn = kFALSE;