]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
092578a7 | 3 | |
d810d0de | 4 | /************************************************************************** |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
092578a7 | 9 | |
d810d0de | 10 | #include "AliEveTPCSectorViz.h" |
11 | ||
cb4245bb | 12 | #include <EveDet/AliEveTPCData.h> |
13 | #include <EveDet/AliEveTPCSectorData.h> | |
092578a7 | 14 | #include <AliTPCParam.h> |
15 | ||
16 | #include <TStyle.h> | |
17 | #include <TColor.h> | |
d810d0de | 18 | |
092578a7 | 19 | |
57ffa5fb | 20 | //______________________________________________________________________________ |
d810d0de | 21 | // AliEveTPCSectorViz |
092578a7 | 22 | // |
23 | // Base class for TPC raw-data visualization. | |
d810d0de | 24 | // See AliEveTPCSector2D and AliEveTPCSector3D for concrete implementations. |
092578a7 | 25 | |
d810d0de | 26 | ClassImp(AliEveTPCSectorViz) |
092578a7 | 27 | |
57ffa5fb | 28 | /******************************************************************************/ |
092578a7 | 29 | |
d810d0de | 30 | AliEveTPCSectorViz::AliEveTPCSectorViz(const Text_t* n, const Text_t* t) : |
84aff7a4 | 31 | TEveElement(fFrameColor), |
27db2029 | 32 | TNamed(n, t), |
092578a7 | 33 | |
34 | fTPCData (0), | |
35 | fSectorID (0), | |
36 | ||
37 | fMinTime (0), | |
38 | fMaxTime (450), | |
39 | fThreshold (5), | |
6124fec9 | 40 | fMaxVal (128), |
092578a7 | 41 | |
42 | fRnrInn (kTRUE), | |
43 | fRnrOut1 (kTRUE), | |
44 | fRnrOut2 (kTRUE), | |
45 | ||
46 | fFrameColor ((Color_t) 4), | |
32e219c2 | 47 | fRnrFrame (kTRUE), |
48 | fAutoTrans (kFALSE), | |
49 | fRTS (1), | |
bd73c30b | 50 | |
51 | fColorArray (0) | |
092578a7 | 52 | {} |
53 | ||
d810d0de | 54 | AliEveTPCSectorViz::~AliEveTPCSectorViz() |
092578a7 | 55 | { |
56 | if(fTPCData) fTPCData->DecRefCount(); | |
bd73c30b | 57 | delete [] fColorArray; |
092578a7 | 58 | } |
59 | ||
d810d0de | 60 | void AliEveTPCSectorViz::CopyVizParams(const AliEveTPCSectorViz& v) |
45664536 | 61 | { |
62 | fMinTime = v.fMinTime; | |
63 | fMaxTime = v.fMaxTime; | |
64 | fThreshold = v.fThreshold; | |
65 | fMaxVal = v.fMaxVal; | |
66 | ||
67 | fRnrInn = v.fRnrInn; | |
68 | fRnrOut1 = v.fRnrOut1; | |
69 | fRnrOut2 = v.fRnrOut2; | |
70 | } | |
71 | ||
57ffa5fb | 72 | /******************************************************************************/ |
092578a7 | 73 | |
d810d0de | 74 | void AliEveTPCSectorViz::SetDataSource(AliEveTPCData* data) |
092578a7 | 75 | { |
76 | if(data == fTPCData) return; | |
77 | if(fTPCData) fTPCData->DecRefCount(); | |
78 | fTPCData = data; | |
79 | if(fTPCData) fTPCData->IncRefCount(); | |
80 | IncRTS(); | |
81 | } | |
82 | ||
d810d0de | 83 | void AliEveTPCSectorViz::SetSectorID(Int_t id) |
092578a7 | 84 | { |
45664536 | 85 | if(id < 0) id = 0; |
86 | if(id > 35) id = 35; | |
87 | fSectorID = id; | |
fbb1b08d | 88 | if(fAutoTrans) |
89 | SetAutoTrans(kTRUE); // Force repositioning. | |
092578a7 | 90 | IncRTS(); |
91 | } | |
92 | ||
d810d0de | 93 | AliEveTPCSectorData* AliEveTPCSectorViz::GetSectorData() const |
092578a7 | 94 | { |
95 | return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0; | |
96 | } | |
97 | ||
57ffa5fb | 98 | /******************************************************************************/ |
092578a7 | 99 | |
d810d0de | 100 | void AliEveTPCSectorViz::SetThreshold(Short_t t) |
bd73c30b | 101 | { |
102 | fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1)); | |
103 | ClearColorArray(); | |
104 | IncRTS(); | |
105 | } | |
106 | ||
d810d0de | 107 | void AliEveTPCSectorViz::SetMaxVal(Int_t mv) |
bd73c30b | 108 | { |
109 | fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1)); | |
110 | ClearColorArray(); | |
111 | IncRTS(); | |
112 | } | |
113 | ||
57ffa5fb | 114 | /******************************************************************************/ |
bd73c30b | 115 | |
51346b82 | 116 | void AliEveTPCSectorViz::SetAutoTrans(Bool_t trans) |
092578a7 | 117 | { |
fbb1b08d | 118 | fAutoTrans = trans; |
119 | if(fAutoTrans) { | |
120 | fHMTrans.UnitTrans(); | |
092578a7 | 121 | |
122 | using namespace TMath; | |
123 | Float_t c = Cos((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); | |
124 | Float_t s = Sin((fSectorID + 0.5)*20*Pi()/180 - PiOver2()); | |
d810d0de | 125 | Float_t z = AliEveTPCSectorData::GetZLength(); |
7e02899d | 126 | Float_t d = -1; |
127 | if(fSectorID >= 18) { | |
128 | z = -z; | |
129 | d = -d; | |
130 | } | |
fbb1b08d | 131 | |
092578a7 | 132 | // column major |
fbb1b08d | 133 | fHMTrans[0] = -c; |
134 | fHMTrans[1] = -s; | |
135 | fHMTrans[4] = -s; | |
136 | fHMTrans[5] = c; | |
137 | fHMTrans[10] = d; | |
138 | fHMTrans[14] = z; | |
139 | fHMTrans[15] = 1; | |
092578a7 | 140 | } |
141 | } | |
142 | ||
57ffa5fb | 143 | /******************************************************************************/ |
092578a7 | 144 | |
d810d0de | 145 | void AliEveTPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const |
092578a7 | 146 | { |
147 | using namespace TMath; | |
148 | Float_t div = Max(1, fMaxVal - fThreshold); | |
149 | Int_t nCol = gStyle->GetNumberOfColors(); | |
150 | Int_t cBin = (Int_t) Nint(nCol*(val - fThreshold)/div); | |
151 | ||
d810d0de | 152 | TEveUtil::TEveUtil::ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel); |
092578a7 | 153 | } |
bd73c30b | 154 | |
d810d0de | 155 | void AliEveTPCSectorViz::ClearColorArray() |
bd73c30b | 156 | { |
157 | if(fColorArray) { | |
158 | delete [] fColorArray; | |
159 | fColorArray = 0; | |
160 | } | |
161 | } | |
162 | ||
d810d0de | 163 | void AliEveTPCSectorViz::SetupColorArray() const |
bd73c30b | 164 | { |
165 | if(fColorArray) | |
166 | return; | |
167 | ||
168 | fColorArray = new UChar_t [4 * (fMaxVal - fThreshold + 1)]; | |
169 | UChar_t* p = fColorArray; | |
170 | for(Int_t v=fThreshold; v<=fMaxVal; ++v, p+=4) | |
171 | SetupColor(v, p); | |
172 | } |