]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/AliEveTPCSectorViz.cxx
Temporary fix to avoid xrootd thrashing
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEveTPCSectorViz.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveTPCSectorViz.h"
11
12 #include <Alieve/AliEveTPCData.h>
13 #include <Alieve/AliEveTPCSectorData.h>
14 #include <AliTPCParam.h>
15
16 #include <TStyle.h>
17 #include <TColor.h>
18
19
20 //______________________________________________________________________________
21 // AliEveTPCSectorViz
22 //
23 // Base class for TPC raw-data visualization.
24 // See AliEveTPCSector2D and AliEveTPCSector3D for concrete implementations.
25
26 ClassImp(AliEveTPCSectorViz)
27
28 /******************************************************************************/
29
30 AliEveTPCSectorViz::AliEveTPCSectorViz(const Text_t* n, const Text_t* t) :
31   TEveElement(fFrameColor),
32   TNamed(n, t),
33
34   fTPCData  (0),
35   fSectorID (0),
36
37   fMinTime   (0),
38   fMaxTime   (450),
39   fThreshold (5),
40   fMaxVal    (128),
41
42   fRnrInn   (kTRUE),
43   fRnrOut1  (kTRUE),
44   fRnrOut2  (kTRUE),
45
46   fFrameColor ((Color_t) 4),
47   fRnrFrame   (kTRUE),
48   fAutoTrans  (kFALSE),
49   fRTS        (1),
50
51   fColorArray (0)
52 {}
53
54 AliEveTPCSectorViz::~AliEveTPCSectorViz()
55 {
56   if(fTPCData) fTPCData->DecRefCount();
57   delete [] fColorArray;
58 }
59
60 void AliEveTPCSectorViz::CopyVizParams(const AliEveTPCSectorViz& v)
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
72 /******************************************************************************/
73
74 void AliEveTPCSectorViz::SetDataSource(AliEveTPCData* data)
75 {
76   if(data == fTPCData) return;
77   if(fTPCData) fTPCData->DecRefCount();
78   fTPCData = data;
79   if(fTPCData) fTPCData->IncRefCount();
80   IncRTS();
81 }
82
83 void AliEveTPCSectorViz::SetSectorID(Int_t id)
84 {
85   if(id < 0)  id = 0;
86   if(id > 35) id = 35;
87   fSectorID = id;
88   if(fAutoTrans)
89     SetAutoTrans(kTRUE); // Force repositioning.
90   IncRTS();
91 }
92
93 AliEveTPCSectorData* AliEveTPCSectorViz::GetSectorData() const
94 {
95   return fTPCData ? fTPCData->GetSectorData(fSectorID) : 0;
96 }
97
98 /******************************************************************************/
99
100 void AliEveTPCSectorViz::SetThreshold(Short_t t)
101 {
102   fThreshold = TMath::Min(t, (Short_t)(fMaxVal - 1));
103   ClearColorArray();
104   IncRTS();
105 }
106
107 void AliEveTPCSectorViz::SetMaxVal(Int_t mv)
108 {
109   fMaxVal = TMath::Max(mv, (Int_t)(fThreshold + 1));
110   ClearColorArray();
111   IncRTS();
112 }
113
114 /******************************************************************************/
115
116 void AliEveTPCSectorViz::SetAutoTrans(Bool_t trans)
117 {
118   fAutoTrans = trans;
119   if(fAutoTrans) {
120     fHMTrans.UnitTrans();
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());
125     Float_t z = AliEveTPCSectorData::GetZLength();
126     Float_t d = -1;
127     if(fSectorID >= 18) {
128       z = -z;
129       d = -d;
130     }
131
132     // column major
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;
140   }
141 }
142
143 /******************************************************************************/
144
145 void AliEveTPCSectorViz::SetupColor(Int_t val, UChar_t* pixel) const
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
152   TEveUtil::TEveUtil::ColorFromIdx(gStyle->GetColorPalette(Min(nCol - 1, cBin)), pixel);
153 }
154
155 void AliEveTPCSectorViz::ClearColorArray()
156 {
157   if(fColorArray) {
158     delete [] fColorArray;
159     fColorArray = 0;
160   }
161 }
162
163 void AliEveTPCSectorViz::SetupColorArray() const
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 }