TTable3Points.cxx

Go to the documentation of this file.
00001 // @(#)root/table:$Id: TTable3Points.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Valery Fine   10/05/99  (E-mail: fine@bnl.gov)
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TTable3Points.h"
00013 
00014 ///////////////////////////////////////////////////////////////////////////////////
00015 //
00016 //   TTable3Points class is to create 3D view of any 3 columns of the TTable objects
00017 //   with one and the same "key column value".
00018 //
00019 //   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
00020 //   from the rows with one and same "track_id" column value will be regarded
00021 //   as an image of one and the same "track".
00022 //   The last means all those points will be painted with one and the same 3D
00023 //   attributes like "color", "size", "style", "light","markers", "connections"  etc.
00024 //
00025 //   The original TTable object must be pre-sorted by "key column" via TTableSorter
00026 //   class
00027 //
00028 // void   CreatePoints(Tg2t_tpc_hit *points)
00029 // {
00030 //   g2t_tpc_hit_st *p = points->GetTable();
00031 //
00032 //  TTable3Points *track = 0;
00033 //  TString tr;
00034 //  tr = "track_p";
00035 //  TTable &ttt = *((TTable *)points);
00036 //  // Track2Line MUST be on heap otherwise 3D view will crash just code leaves this
00037 //  // subroutine
00038 //  We will assemble all points by its "track_p" field.
00039 //
00040 //  TTableSorter *Track2Line = new TTableSorter (ttt,"track_p");
00041 //
00042 //  Int_t i = 0;
00043 //  Char_t buffer[10];
00044 //  Int_t ntracks = 0;
00045 //  const Int_t maxtracks = 5;
00046 ////---------------------------- Fill tracks -------------------
00047 //  long currentId = -1;
00048 //  long newId =  0;
00049 //  g2t_tpc_hit_st *hitPoint = 0;
00050 //  TVolume *thisTrack[7] = {0,0,0,0,0,0,0}; // seven volumes for 7 different colors
00051 //  Int_t  MaxRowtoCount = 5000; // 5000;
00052 //  Int_t  MaxTracks = Track2Line->CountKeys();
00053 //  MaxTracks = 100;
00054 //  for (i=0;i<Track2Line->GetNRows() && ntracks <  MaxTracks ;i++)
00055 //  {
00056 //   hitPoint = p + Track2Line->GetIndex(i);
00057 //   newId =  hitPoint->track_p;
00058 //   if (newId != currentId)  { // The hit for the new track has been found
00059 //
00060 //     const Char_t *xName = "x[0]";
00061 //     const Char_t *yName = "x[1]";
00062 //     const Char_t *zName = "x[2]";
00063 //
00064 //     track =  new TTable3Points(Track2Line,(const void *)&newId,xName,yName,zName);
00065 //
00066 //     // Create a shape for this node
00067 //     TPolyLineShape *trackShape  =  new TPolyLineShape(track);
00068 //     trackShape->SetVisibility(1);
00069 //     Int_t colorIndx = ntracks%7;
00070 //     trackShape->SetColorAttribute(colorIndx+kGreen);
00071 //     trackShape->SetLineStyle(1);
00072 //     trackShape->SetSizeAttribute(2);
00073 //     // Create a node to hold it
00074 //     if (!thisTrack[colorIndx])  {
00075 //         thisTrack[colorIndx] = new TVolume("hits","hits",trackShape);
00076 //         thisTrack[colorIndx]->Mark();
00077 //         thisTrack[colorIndx]->SetVisibility();
00078 //         TVolumePosition *pp = hall->Add(thisTrack[colorIndx]);
00079 //         if (!pp) printf(" no position %d\n",ntrack);
00080 //     }
00081 //     else
00082 //       thisTrack[colorIndx]->Add(trackShape);
00083 //     currentId = newId;
00084 //     ntracks++;
00085 //   }
00086 // }
00087 //
00088 ///////////////////////////////////////////////////////////////////////////////////
00089 
00090 ClassImp(TTable3Points)
00091 
00092 //________________________________________________________________________________
00093 TTable3Points::TTable3Points():fColumnOffset(0)
00094 {
00095    //to be documented
00096 }
00097 
00098 //________________________________________________________________________________
00099 TTable3Points::TTable3Points(TTableSorter *sorter,const void *key,
00100                        const Char_t *xName, const Char_t *yName, const Char_t *zName
00101                       ,Option_t *opt)
00102                 : TTablePoints(sorter,key,opt)
00103 
00104 {
00105    //to be documented
00106    fColumnOffset =  new ULong_t [kTotalSize];
00107    SetXColumn(xName);  SetYColumn(yName);  SetZColumn(zName);
00108 }
00109 
00110 //________________________________________________________________________________
00111 TTable3Points::TTable3Points(TTableSorter *sorter,Int_t keyIndex,
00112                        const Char_t *xName, const Char_t *yName, const Char_t *zName
00113                       ,Option_t *opt)
00114                 : TTablePoints(sorter,keyIndex,opt)
00115 
00116 {
00117    //to be documented
00118    fColumnOffset =  new ULong_t [kTotalSize];
00119    SetXColumn(xName);  SetYColumn(yName);  SetZColumn(zName);
00120 }
00121 
00122 //________________________________________________________________________________
00123 TTable3Points::~TTable3Points()
00124 {
00125    //to be documented
00126    SafeDelete(fColumnOffset);
00127 }
00128 
00129 //________________________________________________________________________________
00130 Float_t TTable3Points::GetAnyPoint(Int_t idx, EPointDirection xAxis) const
00131 {
00132    //to be documented
00133    Float_t point  = 0;
00134    TTable  *table = 0;
00135    if (fTableSorter) table = fTableSorter->GetTable();
00136    if (table) {
00137       const Char_t *tablePtr = ((Char_t *)table->At(Indx(idx))) + fColumnOffset[xAxis] ;
00138       point = *((Float_t *)tablePtr);
00139    }
00140    return point;
00141 }
00142 
00143 //____________________________________________________________________________
00144 void TTable3Points::SetAnyColumn(const Char_t *anyName, EPointDirection indx)
00145 {
00146    //to be documented
00147    fColumnOffset[indx] = fTableSorter->GetTable()->GetOffset(anyName);
00148    if (fColumnOffset[indx] == ULong_t(-1))  MakeZombie();
00149 }
00150 
00151 //____________________________________________________________________________
00152 Float_t *TTable3Points::GetXYZ(Float_t *xyz,Int_t idx, Int_t num) const
00153 {
00154    //to be documented
00155    if (xyz) {
00156       Int_t size = TMath::Min(idx+num,Size());
00157       Int_t j=0;
00158       for (Int_t i=idx;i<size;i++) {
00159          xyz[j++] = GetX(i);
00160          xyz[j++] = GetY(i);
00161          xyz[j++] = GetZ(i);
00162       }
00163    }
00164    return xyz;
00165 }

Generated on Tue Jul 5 14:45:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1