]>
Commit | Line | Data |
---|---|---|
092578a7 | 1 | // $Header$ |
2 | ||
3 | #include "TPCSector3D.h" | |
4 | #include <Alieve/TPCSectorData.h> | |
5 | ||
8ac84a96 | 6 | #include <TBuffer3D.h> |
7 | #include <TBuffer3DTypes.h> | |
8 | #include <TVirtualPad.h> | |
9 | #include <TVirtualViewer3D.h> | |
10 | ||
9a7ad6a0 | 11 | #include <TStyle.h> |
12 | #include <TColor.h> | |
13 | ||
092578a7 | 14 | using namespace Reve; |
15 | using namespace Alieve; | |
16 | ||
17 | //______________________________________________________________________ | |
18 | // TPCSector3D | |
19 | // | |
20 | ||
21 | ClassImp(TPCSector3D) | |
22 | ||
23 | TPCSector3D::TPCSector3D(const Text_t* n, const Text_t* t) : | |
24 | TPCSectorViz(n, t), | |
9a7ad6a0 | 25 | |
26 | fBoxSet (n, t), | |
27 | fPointSetArray(n, t), | |
28 | fPointFrac (0.25), | |
1a351260 | 29 | fPointSize (3), |
092578a7 | 30 | |
092578a7 | 31 | fDriftVel (1), |
32 | fZStep (250.0/450) | |
33 | { | |
8ac84a96 | 34 | fRnrFrame = kFALSE; |
092578a7 | 35 | ComputeBBox(); |
36 | } | |
37 | ||
38 | TPCSector3D::~TPCSector3D() | |
39 | {} | |
40 | ||
41 | /**************************************************************************/ | |
42 | ||
092578a7 | 43 | void TPCSector3D::SetRnrFrame(Bool_t rf) |
44 | { | |
45 | if(fRnrFrame != rf) { | |
46 | fRnrFrame = rf; | |
47 | IncRTS(); | |
48 | } | |
49 | } | |
50 | ||
51 | /**************************************************************************/ | |
52 | ||
53 | void TPCSector3D::ComputeBBox() | |
54 | { | |
55 | const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg(); | |
56 | const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg(); | |
57 | ||
606c4ed7 | 58 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) |
092578a7 | 59 | bbox_init(); |
606c4ed7 | 60 | #else |
61 | BBoxInit(); | |
62 | #endif | |
8ac84a96 | 63 | Float_t w = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth(); |
092578a7 | 64 | fBBox[0] = -w; |
65 | fBBox[1] = w; | |
66 | fBBox[2] = iSeg.GetRLow(); | |
67 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
1a351260 | 68 | fBBox[4] = 0; |
69 | fBBox[5] = TPCSectorData::GetZLength(); | |
66e0d878 | 70 | Float_t* b = fBoxSet.AssertBBox(); |
71 | for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; } | |
72 | ||
092578a7 | 73 | } |
74 | ||
8ac84a96 | 75 | void TPCSector3D::Paint(Option_t* /*option*/) |
092578a7 | 76 | { |
8ac84a96 | 77 | if(fRnrElement == kFALSE) |
78 | return; | |
79 | ||
80 | TBuffer3D buffer(TBuffer3DTypes::kGeneric); | |
81 | ||
82 | // Section kCore | |
83 | buffer.fID = this; | |
84 | buffer.fColor = 1; | |
85 | buffer.fTransparency = 0; | |
86 | buffer.fLocalFrame = fTrans; | |
87 | if (fTrans) | |
88 | memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t)); | |
89 | buffer.SetSectionsValid(TBuffer3D::kCore); | |
90 | ||
91 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer); | |
92 | if (reqSections == TBuffer3D::kNone) { | |
93 | return; | |
5987168b | 94 | } |
092578a7 | 95 | |
8ac84a96 | 96 | printf("TPCSector3D::Paint only GL supported.\n"); |
97 | return; | |
092578a7 | 98 | } |
99 | ||
100 | /**************************************************************************/ | |
101 | ||
102 | void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter, | |
103 | Float_t xs, Float_t ys, Float_t pw, Float_t ph) | |
104 | { | |
105 | Short_t pad, time, val; | |
106 | Float_t x0, x1, z0, z1; | |
9a7ad6a0 | 107 | Float_t ym = ys + 0.5*ph; |
092578a7 | 108 | Float_t ye = ys + ph; |
9a7ad6a0 | 109 | Float_t zs = fZStep/fDriftVel; |
092578a7 | 110 | |
111 | while (iter.NextPad()) { | |
112 | pad = iter.Pad(); | |
113 | while (iter.Next()) { | |
114 | time = iter.Time(); | |
115 | val = iter.Signal(); | |
116 | ||
117 | if(val <= fThreshold || time < fMinTime || time > fMaxTime) | |
118 | continue; | |
119 | ||
9a7ad6a0 | 120 | if(fPointSetOn && val <= fPointSetMaxVal) { |
dcb387f7 | 121 | fPointSetArray.Fill(xs + (pad+0.5)*pw, ym, (time+0.5)*zs, val); |
9a7ad6a0 | 122 | } else { |
123 | fBoxSet.fBoxes.push_back(Reve::Box()); | |
124 | ColorFromArray(val, fBoxSet.fBoxes.back().color); | |
125 | x0 = xs + pad*pw; | |
126 | x1 = x0 + pw; | |
127 | z0 = time*zs; | |
128 | z1 = z0 + zs; | |
129 | Float_t* p = fBoxSet.fBoxes.back().vertices; | |
130 | // front | |
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; | |
135 | // back | |
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; | |
140 | } | |
092578a7 | 141 | } |
142 | } | |
143 | } | |
144 | ||
145 | void TPCSector3D::UpdateBoxes() | |
146 | { | |
147 | // Populate parent class Reve::BoxSet with digit information. | |
148 | ||
149 | // printf("TPCSector3D update boxes\n"); | |
150 | ||
151 | fBoxSet.ClearSet(); | |
dcb387f7 | 152 | fPointSetArray.RemoveElements(); |
092578a7 | 153 | |
154 | TPCSectorData* data = GetSectorData(); | |
155 | if (data != 0) { | |
156 | Bool_t isOn[3]; | |
157 | isOn[0] = fRnrInn; | |
158 | isOn[1] = fRnrOut1; | |
159 | isOn[2] = fRnrOut2; | |
160 | ||
8ac84a96 | 161 | SetupColorArray(); |
9a7ad6a0 | 162 | SetupPointSetArray(); |
8ac84a96 | 163 | |
092578a7 | 164 | // Loop over 3 main segments |
165 | for (Int_t sId = 0; sId <= 2; ++sId) { | |
166 | if(isOn[sId] == kFALSE) | |
167 | continue; | |
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(); | |
175 | } | |
176 | } | |
9a7ad6a0 | 177 | |
178 | if(fPointSetOn) | |
179 | fPointSetArray.CloseBins(); | |
180 | } | |
181 | } | |
182 | ||
183 | void TPCSector3D::SetupPointSetArray() | |
184 | { | |
185 | Int_t nBins = (Int_t) TMath::Nint(fPointFrac*gStyle->GetNumberOfColors()); | |
186 | if(nBins > 0) { | |
187 | fPointSetOn = kTRUE; | |
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); | |
dcb387f7 | 190 | fPointSetArray.InitBins("", nBins, fThreshold, fPointSetMaxVal, kFALSE); |
9a7ad6a0 | 191 | for(Int_t b=0; b<nBins; ++b) { |
192 | fPointSetArray.GetBin(b)->SetMarkerColor(gStyle->GetColorPalette(b)); | |
193 | } | |
194 | } else { | |
195 | fPointSetOn = kFALSE; | |
092578a7 | 196 | } |
092578a7 | 197 | } |