]>
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 | ||
53 | bbox_init(); | |
54 | Float_t w = o2Seg.GetNMaxPads()*o2Seg.GetPadWidth()/2; | |
55 | fBBox[0] = -w; | |
56 | fBBox[1] = w; | |
57 | fBBox[2] = iSeg.GetRLow(); | |
58 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
59 | fBBox[4] = -0.5; | |
60 | fBBox[5] = 250.5; | |
61 | dynamic_cast<TAttBBox&>(fBoxSet) = dynamic_cast<TAttBBox&>(*this); | |
62 | } | |
63 | ||
64 | void TPCSector3D::Paint(Option_t* option) | |
65 | { | |
5987168b | 66 | if(fRnrElement) { |
67 | fBoxSet.SetTrans(fTrans); | |
68 | memcpy(fBoxSet.ArrTrans(), fMatrix, 16*sizeof(Double_t)); | |
092578a7 | 69 | fBoxSet.Paint(option); |
5987168b | 70 | } |
092578a7 | 71 | } |
72 | ||
73 | /**************************************************************************/ | |
74 | ||
75 | void TPCSector3D::MakeFrameBox() | |
76 | { | |
77 | const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg(); | |
78 | const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg(); | |
79 | ||
80 | Float_t x1, x2, y1, y2, D; | |
81 | x1 = 0.5*TPCSectorData::GetNPadsInRow(0)*iSeg.GetPadWidth(); | |
82 | x2 = 0.5*o2Seg.GetNMaxPads()*o2Seg.GetPadWidth(); | |
83 | y1 = iSeg.GetRLow(); | |
84 | y2 = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
85 | D = 0.5*fZStep; | |
86 | ||
87 | ColorFromIdx(fFrameColor, fFrameBox.color); | |
88 | Float_t* p = fFrameBox.vertices; | |
89 | // bottom | |
90 | p[0] = -x1; p[1] = y1; p[2] = -D; p += 3; | |
91 | p[0] = x1; p[1] = y1; p[2] = -D; p += 3; | |
92 | p[0] = x2; p[1] = y2; p[2] = -D; p += 3; | |
93 | p[0] = -x2; p[1] = y2; p[2] = -D; p += 3; | |
94 | // top | |
95 | p[0] = -x1; p[1] = y1; p[2] = D; p += 3; | |
96 | p[0] = x1; p[1] = y1; p[2] = D; p += 3; | |
97 | p[0] = x2; p[1] = y2; p[2] = D; p += 3; | |
98 | p[0] = -x2; p[1] = y2; p[2] = D; p += 3; | |
99 | } | |
100 | ||
101 | /**************************************************************************/ | |
102 | ||
103 | void TPCSector3D::LoadPadrow(TPCSectorData::RowIterator& iter, | |
104 | Float_t xs, Float_t ys, Float_t pw, Float_t ph) | |
105 | { | |
106 | Short_t pad, time, val; | |
107 | Float_t x0, x1, z0, z1; | |
108 | Float_t ye = ys + ph; | |
109 | ||
110 | while (iter.NextPad()) { | |
111 | pad = iter.Pad(); | |
112 | while (iter.Next()) { | |
113 | time = iter.Time(); | |
114 | val = iter.Signal(); | |
115 | ||
116 | if(val <= fThreshold || time < fMinTime || time > fMaxTime) | |
117 | continue; | |
118 | ||
119 | fBoxSet.fBoxes.push_back(Reve::Box()); | |
120 | SetupColor(val, fBoxSet.fBoxes.back().color); | |
121 | x0 = xs + pad*pw; | |
122 | x1 = x0 + pw; | |
123 | z0 = fZStep*time/fDriftVel; | |
124 | z1 = z0 + fZStep/fDriftVel; | |
125 | Float_t* p = fBoxSet.fBoxes.back().vertices; | |
126 | // front | |
127 | p[0] = x0; p[1] = ys; p[2] = z0; p += 3; | |
128 | p[0] = x1; p[1] = ys; p[2] = z0; p += 3; | |
129 | p[0] = x1; p[1] = ye; p[2] = z0; p += 3; | |
130 | p[0] = x0; p[1] = ye; p[2] = z0; p += 3; | |
131 | // back | |
132 | z0 += fZStep; | |
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; | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
141 | void TPCSector3D::UpdateBoxes() | |
142 | { | |
143 | // Populate parent class Reve::BoxSet with digit information. | |
144 | ||
145 | // printf("TPCSector3D update boxes\n"); | |
146 | ||
147 | fBoxSet.ClearSet(); | |
148 | ||
149 | TPCSectorData* data = GetSectorData(); | |
150 | if (data != 0) { | |
151 | Bool_t isOn[3]; | |
152 | isOn[0] = fRnrInn; | |
153 | isOn[1] = fRnrOut1; | |
154 | isOn[2] = fRnrOut2; | |
155 | ||
156 | // Loop over 3 main segments | |
157 | for (Int_t sId = 0; sId <= 2; ++sId) { | |
158 | if(isOn[sId] == kFALSE) | |
159 | continue; | |
160 | const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId); | |
161 | Float_t sy = sInfo.GetRLow(); | |
162 | for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) { | |
163 | TPCSectorData::RowIterator i = data->MakeRowIterator(row); | |
164 | Float_t sx = -0.5*TPCSectorData::GetNPadsInRow(row)*sInfo.GetPadWidth(); | |
165 | LoadPadrow(i, sx, sy, sInfo.GetPadWidth(), sInfo.GetPadHeight()); | |
166 | sy += sInfo.GetPadHeight(); | |
167 | } | |
168 | } | |
169 | } | |
170 | ||
171 | if(fRnrFrame) | |
172 | fBoxSet.fBoxes.push_back(fFrameBox); | |
173 | } |