]>
Commit | Line | Data |
---|---|---|
092578a7 | 1 | // $Header$ |
2 | ||
3 | #include "TPCSector3D.h" | |
4 | #include <Alieve/TPCSectorData.h> | |
5 | ||
6 | using namespace Reve; | |
7 | using namespace Alieve; | |
8 | ||
9 | //______________________________________________________________________ | |
10 | // TPCSector3D | |
11 | // | |
12 | ||
13 | ClassImp(TPCSector3D) | |
14 | ||
15 | TPCSector3D::TPCSector3D(const Text_t* n, const Text_t* t) : | |
16 | TPCSectorViz(n, t), | |
17 | ||
18 | fBoxSet (n, t), | |
19 | fDriftVel (1), | |
20 | fZStep (250.0/450) | |
21 | { | |
22 | fRnrFrame = false; | |
23 | MakeFrameBox(); | |
24 | ComputeBBox(); | |
25 | } | |
26 | ||
27 | TPCSector3D::~TPCSector3D() | |
28 | {} | |
29 | ||
30 | /**************************************************************************/ | |
31 | ||
32 | UInt_t TPCSector3D::IncRTS() | |
33 | { | |
34 | UpdateBoxes(); | |
35 | return ++fRTS; | |
36 | } | |
37 | ||
38 | void TPCSector3D::SetRnrFrame(Bool_t rf) | |
39 | { | |
40 | if(fRnrFrame != rf) { | |
41 | fRnrFrame = rf; | |
42 | IncRTS(); | |
43 | } | |
44 | } | |
45 | ||
46 | /**************************************************************************/ | |
47 | ||
48 | void TPCSector3D::ComputeBBox() | |
49 | { | |
50 | const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg(); | |
51 | const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg(); | |
52 | ||
606c4ed7 | 53 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) |
092578a7 | 54 | bbox_init(); |
606c4ed7 | 55 | #else |
56 | BBoxInit(); | |
57 | #endif | |
092578a7 | 58 | Float_t w = o2Seg.GetNMaxPads()*o2Seg.GetPadWidth()/2; |
59 | fBBox[0] = -w; | |
60 | fBBox[1] = w; | |
61 | fBBox[2] = iSeg.GetRLow(); | |
62 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
63 | fBBox[4] = -0.5; | |
64 | fBBox[5] = 250.5; | |
66e0d878 | 65 | Float_t* b = fBoxSet.AssertBBox(); |
66 | for(Int_t i=0; i<6; ++i) { b[i] = fBBox[i]; } | |
67 | ||
092578a7 | 68 | } |
69 | ||
70 | void TPCSector3D::Paint(Option_t* option) | |
71 | { | |
5987168b | 72 | if(fRnrElement) { |
73 | fBoxSet.SetTrans(fTrans); | |
74 | memcpy(fBoxSet.ArrTrans(), fMatrix, 16*sizeof(Double_t)); | |
092578a7 | 75 | fBoxSet.Paint(option); |
5987168b | 76 | } |
092578a7 | 77 | } |
78 | ||
79 | /**************************************************************************/ | |
80 | ||
81 | void TPCSector3D::MakeFrameBox() | |
82 | { | |
83 | const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg(); | |
84 | const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg(); | |
85 | ||
86 | Float_t x1, x2, y1, y2, D; | |
87 | x1 = 0.5*TPCSectorData::GetNPadsInRow(0)*iSeg.GetPadWidth(); | |
88 | x2 = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth(); | |
89 | y1 = iSeg.GetRLow(); | |
90 | y2 = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
91 | D = 0.5*fZStep; | |
92 | ||
93 | ColorFromIdx(fFrameColor, fFrameBox.color); | |
94 | Float_t* p = fFrameBox.vertices; | |
95 | // bottom | |
96 | p[0] = -x1; p[1] = y1; p[2] = -D; p += 3; | |
97 | p[0] = x1; p[1] = y1; p[2] = -D; p += 3; | |
98 | p[0] = x2; p[1] = y2; p[2] = -D; p += 3; | |
99 | p[0] = -x2; p[1] = y2; p[2] = -D; p += 3; | |
100 | // top | |
101 | p[0] = -x1; p[1] = y1; p[2] = D; p += 3; | |
102 | p[0] = x1; p[1] = y1; p[2] = D; p += 3; | |
103 | p[0] = x2; p[1] = y2; p[2] = D; p += 3; | |
104 | p[0] = -x2; p[1] = y2; p[2] = D; p += 3; | |
105 | } | |
106 | ||
107 | /**************************************************************************/ | |
108 | ||
109 | void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter, | |
110 | Float_t xs, Float_t ys, Float_t pw, Float_t ph) | |
111 | { | |
112 | Short_t pad, time, val; | |
113 | Float_t x0, x1, z0, z1; | |
114 | Float_t ye = ys + ph; | |
115 | ||
116 | while (iter.NextPad()) { | |
117 | pad = iter.Pad(); | |
118 | while (iter.Next()) { | |
119 | time = iter.Time(); | |
120 | val = iter.Signal(); | |
121 | ||
122 | if(val <= fThreshold || time < fMinTime || time > fMaxTime) | |
123 | continue; | |
124 | ||
125 | fBoxSet.fBoxes.push_back(Reve::Box()); | |
126 | SetupColor(val, fBoxSet.fBoxes.back().color); | |
127 | x0 = xs + pad*pw; | |
128 | x1 = x0 + pw; | |
129 | z0 = fZStep*time/fDriftVel; | |
130 | z1 = z0 + fZStep/fDriftVel; | |
131 | Float_t* p = fBoxSet.fBoxes.back().vertices; | |
132 | // front | |
133 | p[0] = x0; p[1] = ys; p[2] = z0; p += 3; | |
134 | p[0] = x1; p[1] = ys; p[2] = z0; p += 3; | |
135 | p[0] = x1; p[1] = ye; p[2] = z0; p += 3; | |
136 | p[0] = x0; p[1] = ye; p[2] = z0; p += 3; | |
137 | // back | |
138 | z0 += fZStep; | |
139 | p[0] = x0; p[1] = ys; p[2] = z0; p += 3; | |
140 | p[0] = x1; p[1] = ys; p[2] = z0; p += 3; | |
141 | p[0] = x1; p[1] = ye; p[2] = z0; p += 3; | |
142 | p[0] = x0; p[1] = ye; p[2] = z0; | |
143 | } | |
144 | } | |
145 | } | |
146 | ||
147 | void TPCSector3D::UpdateBoxes() | |
148 | { | |
149 | // Populate parent class Reve::BoxSet with digit information. | |
150 | ||
151 | // printf("TPCSector3D update boxes\n"); | |
152 | ||
153 | fBoxSet.ClearSet(); | |
154 | ||
155 | TPCSectorData* data = GetSectorData(); | |
156 | if (data != 0) { | |
157 | Bool_t isOn[3]; | |
158 | isOn[0] = fRnrInn; | |
159 | isOn[1] = fRnrOut1; | |
160 | isOn[2] = fRnrOut2; | |
161 | ||
162 | // Loop over 3 main segments | |
163 | for (Int_t sId = 0; sId <= 2; ++sId) { | |
164 | if(isOn[sId] == kFALSE) | |
165 | continue; | |
166 | const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId); | |
167 | Float_t sy = sInfo.GetRLow(); | |
168 | for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) { | |
169 | TPCSectorData::RowIterator i = data->MakeRowIterator(row); | |
170 | Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth(); | |
171 | LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight()); | |
172 | sy += sInfo.GetPadHeight(); | |
173 | } | |
174 | } | |
175 | } | |
176 | ||
177 | if(fRnrFrame) | |
178 | fBoxSet.fBoxes.push_back(fFrameBox); | |
179 | } |