]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSector2D.cxx
Moved code responding to secondary selection from TPCSector2DGL::ProcessSelection...
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSector2D.cxx
1 // $Header$
2
3 #include "TPCSector2D.h"
4
5 #include <Alieve/TPCData.h>
6 #include <Alieve/TPCSectorData.h>
7
8 #include <AliTPCParam.h>
9
10 #include <TBuffer3D.h>
11 #include <TBuffer3DTypes.h>
12 #include <TVirtualPad.h>
13 #include <TVirtualViewer3D.h>
14
15 #include <TH1S.h>
16 #include <TH2S.h>
17 #include <TVirtualPad.h>
18
19 using namespace Reve;
20 using namespace Alieve;
21 using namespace std;
22
23 //______________________________________________________________________
24 // TPCSector2D
25 //
26 // Displays TPC raw-data in 2D.
27 //
28 // fShowMax: true  - display maximum value for given time interval
29 //           false - display integral
30 // fAverage: only available when fShowMax = false; divide by time window width
31 //
32 // fUseTexture: use OpenGL textures to display data (fast rendering,
33 //   updates take the same time)
34 //
35
36 ClassImp(TPCSector2D)
37
38 /**************************************************************************/
39
40 TPCSector2D::TPCSector2D(const Text_t* n, const Text_t* t) :
41   TPCSectorViz(n,t),
42
43   fShowMax (kTRUE),
44   fAverage (kFALSE),
45
46   fUseTexture (kTRUE),
47   fPickEmpty  (kFALSE),
48   fPickMode   (0)
49 {}
50
51 TPCSector2D::~TPCSector2D()
52 {}
53
54 /**************************************************************************/
55
56 void TPCSector2D::ComputeBBox()
57 {
58   const TPCSectorData::SegmentInfo&  iSeg = TPCSectorData::GetInnSeg();
59   const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
60
61 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
62   bbox_init();
63 #else
64   BBoxInit();
65 #endif
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;
73 }
74
75 /**************************************************************************/
76
77 void TPCSector2D::PadSelected(Int_t row, Int_t pad)
78 {
79   // Called when ctrl-mouse-left-click registered over a pad.
80
81   // EVE -> Std convention
82   Int_t sseg = fSectorID, srow = row;
83   if (row >= TPCSectorData::GetInnSeg().GetNRows()) {
84     sseg += 18;
85     srow -= TPCSectorData::GetInnSeg().GetNRows();
86   }
87   switch (fPickMode)
88     {
89     case 0: {
90       printf("TPCSector2DGL::ProcessSelection segment=%d, row=%d, pad=%d\n",
91              sseg, srow, pad);
92       break;
93     }
94     case 1: {
95       TPCSectorData* sectorData = GetSectorData();
96       if (sectorData == 0) return;
97       Int_t mint = fMinTime;
98       Int_t maxt = fMaxTime;
99       TH1S* h = new TH1S(Form("Seg%d_Row%d_Pad%d", sseg, srow, pad),
100                          Form("Segment %d, Row %d, Pad %d", sseg, srow, pad),
101                          maxt - mint +1 , mint, maxt);
102       h->SetXTitle("Time");
103       h->SetYTitle("ADC");
104       TPCSectorData::PadIterator i = sectorData->MakePadIterator(row, pad);
105       while (i.Next())
106         h->Fill(i.Time(), i.Signal());
107       h->Draw();
108       gPad->Modified();
109       gPad->Update();
110       break;
111     }
112     case 2: {
113       TPCSectorData* sectorData = GetSectorData();
114       if (sectorData == 0) return;
115       Int_t mint = fMinTime;
116       Int_t maxt = fMaxTime;
117       Int_t npad = TPCSectorData::GetNPadsInRow(row);
118       TH2S* h = new TH2S(Form("Seg%d_Row%d", sseg, srow),
119                          Form("Segment %d, Row %d", sseg, srow),
120                          maxt - mint +1 , mint, maxt,
121                          npad, 0, npad - 1);
122       h->SetXTitle("Time");
123       h->SetYTitle("Pad");
124       h->SetZTitle("ADC");
125       TPCSectorData::RowIterator i = sectorData->MakeRowIterator(row);
126       while (i.NextPad())
127         while (i.Next())
128           h->Fill(i.Time(), i.Pad(), i.Signal());
129       h->Draw();
130       gPad->Modified();
131       gPad->Update();
132       break;
133     }
134     } // switch
135 }
136
137 /**************************************************************************/
138
139 void TPCSector2D::Paint(Option_t* )
140 {
141   if(fRnrElement == kFALSE)
142     return;
143
144   TBuffer3D buffer(TBuffer3DTypes::kGeneric);
145
146   // Section kCore
147   buffer.fID           = this;
148   buffer.fColor        = 1;
149   buffer.fTransparency = 0;
150   fHMTrans.SetBuffer3D(buffer);
151   buffer.SetSectionsValid(TBuffer3D::kCore);
152    
153   Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
154   if (reqSections == TBuffer3D::kNone) {
155     return;
156   }
157
158   Error("TPCSector2D::Paint", "only direct OpenGL rendering supported.");
159 }