Logo ROOT   6.14/05
Reference Guide
TTable3Points.cxx
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine 10/05/99 (E-mail: fine@bnl.gov)
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TTable3Points.h"
13 
14 ///////////////////////////////////////////////////////////////////////////////////
15 //
16 // TTable3Points class is to create 3D view of any 3 columns of the TTable objects
17 // with one and the same "key column value".
18 //
19 // For example all values of the column "x[0]" "x[1]" "x[2]" of the begin_html <a href="http://www.rhic.bnl.gov/STAR/html/comp_l/root/html/g2t_tpc_hit_st.html"> g2t_tpc_hit </a> end_html table
20 // from the rows with one and same "track_id" column value will be regarded
21 // as an image of one and the same "track".
22 // The last means all those points will be painted with one and the same 3D
23 // attributes like "color", "size", "style", "light","markers", "connections" etc.
24 //
25 // The original TTable object must be pre-sorted by "key column" via TTableSorter
26 // class
27 //
28 // void CreatePoints(Tg2t_tpc_hit *points)
29 // {
30 // g2t_tpc_hit_st *p = points->GetTable();
31 //
32 // TTable3Points *track = 0;
33 // TString tr;
34 // tr = "track_p";
35 // TTable &ttt = *((TTable *)points);
36 // // Track2Line MUST be on heap otherwise 3D view will crash just code leaves this
37 // // subroutine
38 // We will assemble all points by its "track_p" field.
39 //
40 // TTableSorter *Track2Line = new TTableSorter (ttt,"track_p");
41 //
42 // Int_t i = 0;
43 // Char_t buffer[10];
44 // Int_t ntracks = 0;
45 // const Int_t maxtracks = 5;
46 // //---------------------------- Fill tracks -------------------
47 // long currentId = -1;
48 // long newId = 0;
49 // g2t_tpc_hit_st *hitPoint = 0;
50 // TVolume *thisTrack[7] = {0,0,0,0,0,0,0}; // seven volumes for 7 different colors
51 // Int_t MaxRowtoCount = 5000; // 5000;
52 // Int_t MaxTracks = Track2Line->CountKeys();
53 // MaxTracks = 100;
54 // for (i=0;i<Track2Line->GetNRows() && ntracks < MaxTracks ;i++)
55 // {
56 // hitPoint = p + Track2Line->GetIndex(i);
57 // newId = hitPoint->track_p;
58 // if (newId != currentId) { // The hit for the new track has been found
59 //
60 // const Char_t *xName = "x[0]";
61 // const Char_t *yName = "x[1]";
62 // const Char_t *zName = "x[2]";
63 //
64 // track = new TTable3Points(Track2Line,(const void *)&newId,xName,yName,zName);
65 //
66 // // Create a shape for this node
67 // TPolyLineShape *trackShape = new TPolyLineShape(track);
68 // trackShape->SetVisibility(1);
69 // Int_t colorIndx = ntracks%7;
70 // trackShape->SetColorAttribute(colorIndx+kGreen);
71 // trackShape->SetLineStyle(1);
72 // trackShape->SetSizeAttribute(2);
73 // // Create a node to hold it
74 // if (!thisTrack[colorIndx]) {
75 // thisTrack[colorIndx] = new TVolume("hits","hits",trackShape);
76 // thisTrack[colorIndx]->Mark();
77 // thisTrack[colorIndx]->SetVisibility();
78 // TVolumePosition *pp = hall->Add(thisTrack[colorIndx]);
79 // if (!pp) printf(" no position %d\n",ntrack);
80 // }
81 // else
82 // thisTrack[colorIndx]->Add(trackShape);
83 // currentId = newId;
84 // ntracks++;
85 // }
86 // }
87 //
88 ///////////////////////////////////////////////////////////////////////////////////
89 
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 ///to be documented
94 
95 TTable3Points::TTable3Points():fColumnOffset(0)
96 {
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 
102  const Char_t *xName, const Char_t *yName, const Char_t *zName
103  ,Option_t *opt)
104  : TTablePoints(sorter,key,opt)
105 
106 {
107  //to be documented
109  SetXColumn(xName); SetYColumn(yName); SetZColumn(zName);
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 
115  const Char_t *xName, const Char_t *yName, const Char_t *zName
116  ,Option_t *opt)
117  : TTablePoints(sorter,keyIndex,opt)
118 
119 {
120  //to be documented
122  SetXColumn(xName); SetYColumn(yName); SetZColumn(zName);
123 }
124 
125 ////////////////////////////////////////////////////////////////////////////////
126 ///to be documented
127 
129 {
131 }
132 
133 ////////////////////////////////////////////////////////////////////////////////
134 ///to be documented
135 
137 {
138  Float_t point = 0;
139  TTable *table = 0;
140  if (fTableSorter) table = fTableSorter->GetTable();
141  if (table) {
142  const Char_t *tablePtr = ((Char_t *)table->At(Indx(idx))) + fColumnOffset[xAxis] ;
143  point = *((Float_t *)tablePtr);
144  }
145  return point;
146 }
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 ///to be documented
150 
152 {
153  fColumnOffset[indx] = fTableSorter->GetTable()->GetOffset(anyName);
154  if (fColumnOffset[indx] == ULong_t(-1)) MakeZombie();
155 }
156 
157 ////////////////////////////////////////////////////////////////////////////////
158 ///to be documented
159 
161 {
162  if (xyz) {
163  Int_t size = TMath::Min(idx+num,Size());
164  Int_t j=0;
165  for (Int_t i=idx;i<size;i++) {
166  xyz[j++] = GetX(i);
167  xyz[j++] = GetY(i);
168  xyz[j++] = GetZ(i);
169  }
170  }
171  return xyz;
172 }
virtual Int_t Size() const
Definition: TTablePoints.h:68
virtual TTable * GetTable() const
to be documented
TTableSorter * fTableSorter
Definition: TTablePoints.h:22
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual void SetXColumn(const Char_t *xName)
Definition: TTable3Points.h:35
virtual const Float_t * GetXYZ(Int_t)
Definition: TTable3Points.h:49
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:168
int Int_t
Definition: RtypesCore.h:41
virtual void SetYColumn(const Char_t *yName)
Definition: TTable3Points.h:36
virtual Float_t GetX(Int_t idx) const
Definition: TTable3Points.h:44
ULong_t * fColumnOffset
Definition: TTable3Points.h:20
virtual void SetZColumn(const Char_t *zName)
Definition: TTable3Points.h:37
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
Definition: TTable.cxx:302
virtual Float_t GetAnyPoint(Int_t idx, EPointDirection xAxis) const
to be documented
virtual Int_t Indx(Int_t sortedIndx) const
Definition: TTablePoints.h:55
~TTable3Points()
to be documented
virtual Float_t GetZ(Int_t idx) const
Definition: TTable3Points.h:46
virtual Float_t GetY(Int_t idx) const
Definition: TTable3Points.h:45
#define SafeDelete(p)
Definition: RConfig.h:529
virtual void SetAnyColumn(const Char_t *anyName, EPointDirection indx)
to be documented
#define ClassImp(name)
Definition: Rtypes.h:359
unsigned long ULong_t
Definition: RtypesCore.h:51
TTable3Points()
to be documented
Definition: TTable.h:48
char Char_t
Definition: RtypesCore.h:29
void MakeZombie()
Definition: TObject.h:49
virtual UInt_t GetOffset(Int_t columnIndex) const
Definition: TTable.cxx:2424