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) :
38 TPCSector3D::~TPCSector3D()
41 /**************************************************************************/
43 void TPCSector3D::SetRnrFrame(Bool_t rf)
51 /**************************************************************************/
53 void TPCSector3D::ComputeBBox()
55 const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg();
56 const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
58 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
63 Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth();
66 fBBox[2] = iSeg.GetRLow();
67 fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
69 fBBox[5] = TPCSectorData::GetZLength();
70 Float_t* b = fBoxSet.AssertBBox();
71 for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; }
75 void TPCSector3D::Paint(Option_t* /*option*/)
77 if(fRnrElement == kFALSE)
80 TBuffer3D buffer(TBuffer3DTypes::kGeneric);
85 buffer.fTransparency = 0;
86 buffer.fLocalFrame = fTrans;
88 memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t));
89 buffer.SetSectionsValid(TBuffer3D::kCore);
91 Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
92 if (reqSections == TBuffer3D::kNone) {
96 printf("TPCSector3D::Paint only GL supported.\n");
100 /**************************************************************************/
102 void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter,
103 Float_t xs, Float_t ys, Float_t pw, Float_t ph)
105 Short_t pad, time, val;
106 Float_t x0, x1, z0, z1;
107 Float_t ym = ys + 0.5*ph;
108 Float_t ye = ys + ph;
109 Float_t zs = fZStep/fDriftVel;
111 while (iter.NextPad()) {
113 while (iter.Next()) {
117 if(val <= fThreshold || time < fMinTime || time > fMaxTime)
120 if(fPointSetOn && val <= fPointSetMaxVal) {
121 fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val);
123 fBoxSet.fBoxes.push_back(Reve::Box());
124 ColorFromArray(val, fBoxSet.fBoxes.back().color);
129 Float_t* p = fBoxSet.fBoxes.back().vertices;
131 p[0] = x0; p[1] = ys; p[2] = z0; p += 3;
132 p[0] = x1; p[1] = ys; p[2] = z0; p += 3;
133 p[0] = x1; p[1] = ye; p[2] = z0; p += 3;
134 p[0] = x0; p[1] = ye; p[2] = z0; p += 3;
136 p[0] = x0; p[1] = ys; p[2] = z1; p += 3;
137 p[0] = x1; p[1] = ys; p[2] = z1; p += 3;
138 p[0] = x1; p[1] = ye; p[2] = z1; p += 3;
139 p[0] = x0; p[1] = ye; p[2] = z1;
145 void TPCSector3D::UpdateBoxes()
147 // Populate parent class Reve::BoxSet with digit information.
149 // printf("TPCSector3D update boxes\n");
152 fPointSetArray.RemoveElements();
154 TPCSectorData* data = GetSectorData();
162 SetupPointSetArray();
164 // Loop over 3 main segments
165 for (Int_t sId = 0; sId <= 2; ++sId) {
166 if(isOn[sId] == kFALSE)
168 const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
169 Float_t sy = sInfo.GetRLow();
170 for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
171 TPCSectorData::RowIterator i = data->MakeRowIterator(row);
172 Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth();
173 LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight());
174 sy += sInfo.GetPadHeight();
179 fPointSetArray.CloseBins();
183 void TPCSector3D::SetupPointSetArray()
185 Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors());
188 fPointSetMaxVal = fThreshold + (Int_t) TMath::Nint(fPointFrac*(fMaxVal - fThreshold));
189 // printf("SetupPointSetArray frac=%f nbins=%d psmv=%d (%d,%d)\n", fPointFrac, nBins, fPointSetMaxVal, fThreshold, fMaxVal);
190 fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE);
191 for(Int_t b=0; b<nBins; ++b) {
192 fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b));
195 fPointSetOn = kFALSE;