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