]>
Commit | Line | Data |
---|---|---|
915dabe1 | 1 | #include "TPCSector2D.h" |
5a5a1232 | 2 | |
915dabe1 | 3 | #include <Alieve/TPCData.h> |
4 | #include <Alieve/TPCSectorData.h> | |
5 | ||
6 | #include <AliTPCParam.h> | |
5a5a1232 | 7 | |
8 | using namespace Reve; | |
9 | using namespace Alieve; | |
10 | using namespace std; | |
11 | ||
2aef44c1 | 12 | ClassImp(TPCSector2D) |
5a5a1232 | 13 | |
14 | /**************************************************************************/ | |
15 | ||
915dabe1 | 16 | void TPCSector2D::Init() |
5a5a1232 | 17 | { |
915dabe1 | 18 | fTPCData = 0; |
5a5a1232 | 19 | |
915dabe1 | 20 | fSectorID = 0; |
21 | fShowMax = true; | |
5a5a1232 | 22 | fMinTime = 0; |
23 | fMaxTime = 1; | |
915dabe1 | 24 | fthreshold = 5; |
5a5a1232 | 25 | fMaxVal = 80; |
915dabe1 | 26 | |
27 | fRnrFrame = true; | |
28 | fUseTexture = true; | |
29 | ||
30 | fTrans = false; | |
5a5a1232 | 31 | } |
32 | ||
915dabe1 | 33 | TPCSector2D::~TPCSector2D() |
5a5a1232 | 34 | { |
915dabe1 | 35 | if(fTPCData) fTPCData->DecRefCount(); |
5a5a1232 | 36 | } |
37 | ||
38 | /**************************************************************************/ | |
39 | ||
915dabe1 | 40 | void TPCSector2D::SetDataSource(TPCData* data) |
5a5a1232 | 41 | { |
915dabe1 | 42 | if(data == fTPCData) return; |
43 | if(fTPCData) fTPCData->DecRefCount(); | |
44 | fTPCData = data; | |
45 | if(fTPCData) fTPCData->IncRefCount(); | |
46 | ++fRTS; | |
5a5a1232 | 47 | } |
48 | ||
915dabe1 | 49 | void TPCSector2D::SetSectorID(Int_t segment) |
5a5a1232 | 50 | { |
51 | if(segment < 0 ) segment = 0; | |
915dabe1 | 52 | if(segment > 35) segment = 35; |
53 | fSectorID = segment; | |
54 | SetName(Form("TPCSector2D %d", fSectorID)); | |
5a5a1232 | 55 | ++fRTS; |
56 | } | |
57 | ||
58 | /**************************************************************************/ | |
59 | ||
915dabe1 | 60 | void TPCSector2D::ComputeBBox() |
5a5a1232 | 61 | { |
915dabe1 | 62 | const TPCSectorData::SegmentInfo& iSeg = TPCSectorData::GetInnSeg(); |
63 | const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg(); | |
5a5a1232 | 64 | |
65 | bbox_init(); | |
915dabe1 | 66 | Float_t w = o2Seg.GetNMaxPads()*o2Seg.GetPadWidth()/2; |
67 | fBBox[0] = -w; | |
68 | fBBox[1] = w; | |
69 | fBBox[2] = iSeg.GetRLow(); | |
70 | fBBox[3] = o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight(); | |
71 | fBBox[4] = -0.5; // Fake z-width to 1 cm. | |
72 | fBBox[5] = 0.5; | |
5a5a1232 | 73 | } |
74 | ||
75 | /**************************************************************************/ | |
76 | ||
915dabe1 | 77 | void TPCSector2D::SetTrans(Bool_t trans) |
5a5a1232 | 78 | { |
79 | fTrans = trans; | |
80 | if(fTrans) { | |
81 | for (Int_t k = 0; k< 16; k++) | |
82 | fMatrix[k] = 0.; | |
83 | ||
915dabe1 | 84 | Float_t c = TMath::Cos((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2); |
85 | Float_t s = TMath::Sin((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2); | |
86 | Float_t z = TPCSectorData::GetParam().GetZLength(); | |
87 | if(fSectorID >= 18) z = -z; | |
5a5a1232 | 88 | |
915dabe1 | 89 | // column major |
90 | fMatrix[0] = -c; | |
91 | fMatrix[1] = -s; | |
92 | fMatrix[4] = -s; | |
93 | fMatrix[5] = c; | |
5a5a1232 | 94 | fMatrix[10] = -1; |
915dabe1 | 95 | fMatrix[14] = z; |
96 | fMatrix[15] = 1; | |
5a5a1232 | 97 | } |
98 | } | |
99 | ||
100 | /**************************************************************************/ | |
915dabe1 | 101 | |
102 | void TPCSector2D::Paint(Option_t* ) | |
5a5a1232 | 103 | { |
104 | TBuffer3D buffer(TBuffer3DTypes::kGeneric); | |
105 | ||
106 | // Section kCore | |
107 | buffer.fID = this; | |
108 | buffer.fColor = 1; | |
109 | buffer.fTransparency = 0; | |
110 | buffer.fLocalFrame = fTrans; | |
5a5a1232 | 111 | if (fTrans) |
112 | memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t)); | |
113 | buffer.SetSectionsValid(TBuffer3D::kCore); | |
114 | ||
5a5a1232 | 115 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer); |
116 | if (reqSections == TBuffer3D::kNone) { | |
915dabe1 | 117 | // printf("TPCSector2D::Paint viewer was happy with Core buff3d.\n"); |
5a5a1232 | 118 | return; |
119 | } | |
915dabe1 | 120 | |
121 | printf("TPCSector2D::Paint only GL supported.\n"); | |
5a5a1232 | 122 | return; |
915dabe1 | 123 | |
5a5a1232 | 124 | /* |
125 | if (reqSections & TBuffer3D::kRawSizes) { | |
126 | Int_t nbPnts = fQuads.size()*4; | |
127 | Int_t nbSegs = nbPnts; | |
128 | if (!buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, fQuads.size(), fQuads.size()*6)) { | |
129 | return; | |
130 | } | |
131 | buffer.SetSectionsValid(TBuffer3D::kRawSizes); | |
132 | } | |
133 | ||
134 | if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) { | |
135 | // Points | |
136 | Int_t pidx = 0; | |
137 | for (std::vector<Quad>::iterator i=fQuads.begin(); i!=fQuads.end(); ++i) { | |
138 | for (Int_t k = 0; k < 12; k++ ){ | |
139 | buffer.fPnts[pidx] = (*i).vertices[k]; | |
140 | pidx++; | |
141 | } | |
142 | } | |
143 | ||
144 | // Segments | |
145 | Int_t sidx = 0; | |
146 | for (Int_t q = 0; q < fQuads.size(); ++q) { | |
147 | for (Int_t s = 0; s < 4; ++s ) { | |
148 | buffer.fSegs[3*sidx ] = 4; | |
149 | buffer.fSegs[3*sidx+1] = sidx; | |
150 | if (s == 3) | |
151 | buffer.fSegs[3*sidx+2] = q*4; | |
152 | else | |
153 | buffer.fSegs[3*sidx+2] = sidx + 1; | |
154 | sidx ++; | |
155 | } | |
156 | } | |
157 | ||
158 | // Polygons | |
159 | for (Int_t q = 0; q < fQuads.size(); ++q) { | |
160 | buffer.fPols[6*q] = fQuads[q].color; | |
161 | buffer.fPols[6*q +1] = 4; | |
162 | buffer.fPols[6*q +2] = 4*q +0; | |
163 | buffer.fPols[6*q +3] = 4*q +1; | |
164 | buffer.fPols[6*q +4] = 4*q +2; | |
165 | buffer.fPols[6*q +5] = 4*q +3; | |
166 | } | |
167 | ||
168 | buffer.SetSectionsValid(TBuffer3D::kRaw); | |
169 | buffer.fColor = 5; | |
170 | } | |
171 | ||
172 | */ | |
173 | // gPad->GetViewer3D()->AddObject(buffer); | |
174 | } |