092578a7 |
1 | // $Header$ |
2 | |
3 | #include "TPCSectorViz.h" |
4 | |
5 | #include <Alieve/TPCData.h> |
6 | #include <Alieve/TPCSectorData.h> |
7 | #include <AliTPCParam.h> |
8 | |
9 | #include <TStyle.h> |
10 | #include <TColor.h> |
11 | |
12 | using namespace Reve; |
13 | using namespace Alieve; |
14 | |
15 | //______________________________________________________________________ |
16 | // TPCSectorViz |
17 | // |
18 | // Base class for TPC raw-data visualization. |
19 | // See TPCSector2D and TPCSector3D for concrete implementations. |
20 | |
21 | ClassImp(TPCSectorViz) |
22 | |
23 | /**************************************************************************/ |
24 | |
25 | TPCSectorViz::TPCSectorViz(const Text_t* n, const Text_t* t) : |
26 | TNamed(n, t), |
27 | Reve::RenderElement(fFrameColor), |
28 | |
29 | fTPCData (0), |
30 | fSectorID (0), |
31 | |
32 | fMinTime (0), |
33 | fMaxTime (450), |
34 | fThreshold (5), |
35 | fMaxVal (80), |
36 | |
37 | fRnrInn (kTRUE), |
38 | fRnrOut1 (kTRUE), |
39 | fRnrOut2 (kTRUE), |
40 | |
41 | fFrameColor ((Color_t) 4), |
42 | fRnrFrame (kTRUE), |
43 | fTrans (kFALSE), |
44 | fRTS (1) |
45 | {} |
46 | |
47 | TPCSectorViz::~TPCSectorViz() |
48 | { |
49 | if(fTPCData) fTPCData->DecRefCount(); |
50 | } |
51 | |
52 | /**************************************************************************/ |
53 | |
092578a7 |
54 | void TPCSectorViz::SetDataSource(TPCData* data) |
55 | { |
56 | if(data == fTPCData) return; |
57 | if(fTPCData) fTPCData->DecRefCount(); |
58 | fTPCData = data; |
59 | if(fTPCData) fTPCData->IncRefCount(); |
60 | IncRTS(); |
61 | } |
62 | |
63 | void TPCSectorViz::SetSectorID(Int_t segment) |
64 | { |
65 | if(segment < 0 ) segment = 0; |
66 | if(segment > 35) segment = 35; |
67 | fSectorID = segment; |
68 | IncRTS(); |
69 | } |
70 | |
71 | TPCSectorData* TPCSectorViz::GetSectorData() const |
72 | { |
73 | return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0; |
74 | } |
75 | |
76 | /**************************************************************************/ |
77 | |
78 | void TPCSectorViz::SetTrans(Bool_t trans) |
79 | { |
80 | fTrans = trans; |
81 | if(fTrans) { |
82 | for (Int_t k=0; k<16; ++k) |
83 | fMatrix[k] = 0.; |
84 | |
85 | using namespace TMath; |
86 | Float_t c = Cos((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); |
87 | Float_t s = Sin((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); |
88 | Float_t z = TPCSectorData::GetParam().GetZLength(); |
89 | if(fSectorID >= 18) z = -z; |
90 | |
91 | // column major |
92 | fMatrix[0] = -c; |
93 | fMatrix[1] = -s; |
94 | fMatrix[4] = -s; |
95 | fMatrix[5] = c; |
96 | fMatrix[10] = -1; |
97 | fMatrix[14] = z; |
98 | fMatrix[15] = 1; |
99 | } |
100 | } |
101 | |
102 | /**************************************************************************/ |
103 | |
104 | void TPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const |
105 | { |
106 | using namespace TMath; |
107 | Float_t div = Max(1, fMaxVal - fThreshold); |
108 | Int_t nCol = gStyle->GetNumberOfColors(); |
109 | Int_t cBin = (Int_t) Nint(nCol*(val - fThreshold)/div); |
110 | |
111 | ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel); |
112 | } |