]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveTPCSector2D.cxx
aed7fbca0f0f9b1a5fc8cf8224aac7884702a534
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCSector2D.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 "AliEveTPCSector2D.h"
11 #include "AliEveTPCSector3D.h"
12
13 #include <EveDet/AliEveTPCData.h>
14 #include <EveDet/AliEveTPCSectorData.h>
15
16 #include <TEveManager.h>
17
18 #include <AliTPCParam.h>
19
20 #include <TBuffer3D.h>
21 #include <TBuffer3DTypes.h>
22 #include <TVirtualPad.h>
23 #include <TVirtualViewer3D.h>
24
25 #include <TH1S.h>
26 #include <TH2S.h>
27 #include <TVirtualPad.h>
28
29 using namespace std;
30
31 //______________________________________________________________________________
32 // AliEveTPCSector2D
33 //
34 // Displays TPC raw-data in 2D.
35 //
36 // fShowMax: true  - display maximum value for given time interval
37 //           false - display integral
38 // fAverage: only available when fShowMax = false; divide by time window width
39 //
40 // fUseTexture: use OpenGL textures to display data (fast rendering,
41 //   updates take the same time)
42 //
43
44 ClassImp(AliEveTPCSector2D)
45
46 /******************************************************************************/
47
48 AliEveTPCSector2D::AliEveTPCSector2D(const Text_t* n, const Text_t* t) :
49   AliEveTPCSectorViz(n,t),
50
51   fShowMax (kTRUE),
52   fAverage (kFALSE),
53
54   fUseTexture (kTRUE),
55   fPickEmpty  (kFALSE),
56   fPickMode   (1)
57 {
58   // Constructor.
59 }
60
61 /******************************************************************************/
62
63 void AliEveTPCSector2D::MakeSector3D()
64 {
65   // Make a 3D sector with same setting as this one.
66   // It is added as a child ot this object.
67
68   AliEveTPCSector3D* s = new AliEveTPCSector3D;
69   s->SetDataSource(fTPCData);
70   s->SetSectorID(fSectorID);
71   s->SetAutoTrans(fAutoTrans);
72   s->CopyVizParams(*this);
73   gEve->AddElement(s, this);
74   gEve->Redraw3D();
75 }
76
77 /******************************************************************************/
78
79 void AliEveTPCSector2D::ComputeBBox()
80 {
81   // Compute boundig-box.
82
83   const AliEveTPCSectorData::SegmentInfo&  iSeg = AliEveTPCSectorData::GetInnSeg();
84   const AliEveTPCSectorData::SegmentInfo& o2Seg = AliEveTPCSectorData::GetOut2Seg();
85
86   BBoxInit();
87   Float_t w = o2Seg.GetNMaxPads()*o2Seg.GetPadWidth()/2;
88   fBBox[0] = -w;
89   fBBox[1] =  w;
90   fBBox[2] =  iSeg.GetRLow();
91   fBBox[3] =  o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
92   fBBox[4] = -0.5; // Fake z-width to 1 cm.
93   fBBox[5] =  0.5;
94 }
95
96 /******************************************************************************/
97
98 void AliEveTPCSector2D::PadSelected(Int_t row, Int_t pad)
99 {
100   // Called when ctrl-mouse-left-click registered over a pad.
101
102   // EVE -> Std convention
103   Int_t sseg = fSectorID, srow = row;
104   if (row >= AliEveTPCSectorData::GetInnSeg().GetNRows()) {
105     sseg += 36;
106     srow -= AliEveTPCSectorData::GetInnSeg().GetNRows();
107   }
108   switch (fPickMode)
109     {
110     case 0: {
111       printf("AliEveTPCSector2DGL::ProcessSelection segment=%d, row=%d, pad=%d\n",
112              sseg, srow, pad);
113       break;
114     }
115     case 1: {
116       AliEveTPCSectorData* sectorData = GetSectorData();
117       if (sectorData == 0) return;
118       Int_t mint = fMinTime;
119       Int_t maxt = fMaxTime;
120       TH1S* h = new TH1S(Form("Seg%d_Row%d_TEvePad%d", sseg, srow, pad),
121                          Form("Segment %d, Row %d, TEvePad %d", sseg, srow, pad),
122                          maxt - mint +1 , mint, maxt);
123       h->SetXTitle("Time");
124       h->SetYTitle("ADC");
125       AliEveTPCSectorData::PadIterator i = sectorData->MakePadIterator(row, pad);
126       while (i.Next())
127         h->Fill(i.Time(), i.Signal());
128       h->Draw();
129       gPad->Modified();
130       gPad->Update();
131       break;
132     }
133     case 2: {
134       AliEveTPCSectorData* sectorData = GetSectorData();
135       if (sectorData == 0) return;
136       Int_t mint = fMinTime;
137       Int_t maxt = fMaxTime;
138       Int_t npad = AliEveTPCSectorData::GetNPadsInRow(row);
139       TH2S* h = new TH2S(Form("Seg%d_Row%d", sseg, srow),
140                          Form("Segment %d, Row %d", sseg, srow),
141                          maxt - mint +1 , mint, maxt,
142                          npad, 0, npad - 1);
143       h->SetXTitle("Time");
144       h->SetYTitle("TEvePad");
145       h->SetZTitle("ADC");
146       AliEveTPCSectorData::RowIterator i = sectorData->MakeRowIterator(row);
147       while (i.NextPad())
148         while (i.Next())
149           h->Fill(i.Time(), i.TEvePad(), i.Signal());
150       h->Draw();
151       gPad->Modified();
152       gPad->Update();
153       break;
154     }
155     } // switch
156 }
157
158 /******************************************************************************/
159
160 void AliEveTPCSector2D::Paint(Option_t* )
161 {
162   // Paint object.
163
164   if(fRnrSelf == kFALSE)
165     return;
166
167   TBuffer3D buffer(TBuffer3DTypes::kGeneric);
168
169   // Section kCore
170   buffer.fID           = this;
171   buffer.fColor        = 1;
172   buffer.fTransparency = 0;
173   fHMTrans.SetBuffer3D(buffer);
174   buffer.SetSectionsValid(TBuffer3D::kCore);
175
176   Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
177   if (reqSections == TBuffer3D::kNone) {
178     return;
179   }
180
181   Error("AliEveTPCSector2D::Paint", "only direct OpenGL rendering supported.");
182 }