Merge EVE-dev to HEAD.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 May 2006 10:45:37 +0000 (10:45 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 May 2006 10:45:37 +0000 (10:45 +0000)
38 files changed:
EVE/Alieve/.SKEL.cxx
EVE/Alieve/ChangeLog [new file with mode: 0644]
EVE/Alieve/ITSModule.cxx
EVE/Alieve/LinkDef.h
EVE/Alieve/TPCData.cxx [new file with mode: 0644]
EVE/Alieve/TPCData.h [new file with mode: 0644]
EVE/Alieve/TPCDigitsInfo.cxx [deleted file]
EVE/Alieve/TPCDigitsInfo.h [deleted file]
EVE/Alieve/TPCSector2D.cxx [moved from EVE/Alieve/TPCSegment.cxx with 59% similarity]
EVE/Alieve/TPCSector2D.h [new file with mode: 0644]
EVE/Alieve/TPCSector2DEditor.cxx [moved from EVE/Alieve/TPCSegmentEditor.cxx with 55% similarity]
EVE/Alieve/TPCSector2DEditor.h [new file with mode: 0644]
EVE/Alieve/TPCSector2DGL.cxx [new file with mode: 0644]
EVE/Alieve/TPCSector2DGL.h [new file with mode: 0644]
EVE/Alieve/TPCSectorData.cxx [new file with mode: 0644]
EVE/Alieve/TPCSectorData.h [new file with mode: 0644]
EVE/Alieve/TPCSegment.h [deleted file]
EVE/Alieve/TPCSegmentEditor.h [deleted file]
EVE/Alieve/TPCSegmentGL.cxx [deleted file]
EVE/Alieve/TPCSegmentGL.h [deleted file]
EVE/ChangeLog [new file with mode: 0644]
EVE/README
EVE/Reve/.SKEL.cxx
EVE/Reve/BoxSet.cxx [new file with mode: 0644]
EVE/Reve/BoxSet.h [new file with mode: 0644]
EVE/Reve/BoxSetGL.cxx [new file with mode: 0644]
EVE/Reve/BoxSetGL.h [new file with mode: 0644]
EVE/Reve/ChangeLog [new file with mode: 0644]
EVE/Reve/LinkDef.h
EVE/Reve/RGTopFrame.cxx
EVE/Reve/Reve.cxx
EVE/Reve/Reve.h
EVE/alice-macros/tpc_digits.C
EVE/libAlieve.pkg
EVE/macros/alieve_loadlibs.C
EVE/reve-genclass.pl [new file with mode: 0755]
EVE/test-macros/tpc_digi_test.C [new file with mode: 0644]
EVE/test-macros/tpc_raw_test.C [new file with mode: 0644]

index 84b5c77..7808390 100644 (file)
@@ -2,6 +2,8 @@
 
 #include "CLASS.h"
 
+using namespace Reve;
+using namespace Alieve;
 
 //______________________________________________________________________
 // CLASS
@@ -9,9 +11,6 @@
 
 ClassImp(CLASS);
 
-using namespace Reve;
-using namespace Alieve;
-
 CLASS::CLASS()
 {
 
diff --git a/EVE/Alieve/ChangeLog b/EVE/Alieve/ChangeLog
new file mode 100644 (file)
index 0000000..c047281
--- /dev/null
@@ -0,0 +1,63 @@
+2006-05-18  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * ITSModule.cxx:
+       * TPCSector2D.cxx:
+       * TPCSector2D.h:
+       * TPCSector2DEditor.cxx:
+       * TPCSector2DEditor.h:
+       * TPCSector2DGL.cxx:
+       Fixed all occurrences of misspelled 'treshold'.
+
+2006-05-18  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * TPCData.cxx:
+       * TPCData.h:
+       In LoadRaw(AliTPCRawStreamOld&): added protection for pad id
+       exceeding number of pads in row; optionally warn of the occurrences.
+
+       * TPCSectorData.cxx:
+       Fix compilation warnings.
+
+2006-05-17  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       Introduce support for reading of raw TPC data. At the same time
+       the TPCSegment* classes have been renamed to TPCSector*.
+       
+       * TPCDigitsInfo.cxx:
+       * TPCDigitsInfo.h:
+       * TPCSegment.cxx:
+       * TPCSegment.h:
+       * TPCSegmentEditor.cxx:
+       * TPCSegmentEditor.h:
+       * TPCSegmentGL.cxx:
+       * TPCSegmentGL.h:
+       Removed files; functionality moved to TPCData* and TPCSector*
+       classes.
+
+       * TPCData.cxx:
+       * TPCData.h:
+       * TPCSector2D.cxx:
+       * TPCSector2D.h:
+       * TPCSector2DEditor.cxx:
+       * TPCSector2DEditor.h:
+       * TPCSector2DGL.cxx:
+       * TPCSector2DGL.h:
+       * TPCSectorData.cxx:
+       * TPCSectorData.h:
+       New files: most of the code was scavenged from TPCDigitsInfo and
+       TPCSegment* classes.
+
+       * LinkDef.h:
+       Reflect new class-names.
+
+       * .SKEL.cxx:
+       Moved using declarations to front.
+
+       * ChangeLog:
+       New file.
index 20b25ea..01bed5c 100644 (file)
@@ -107,7 +107,7 @@ void ITSModule::LoadQuads()
   // printf("its module load quads \n");
   Float_t x = fDx;
   Float_t z = fDz;
-  Bool_t above_treshold = false;
+  Bool_t aboveThreshold = false;
 
   // Module frame in xy plane
   fQuads.push_back(Reve::Quad(fFrameCol));
@@ -130,7 +130,7 @@ void ITSModule::LoadQuads()
   switch(fDetID) {
 
   case 0: { // SPD
-    above_treshold = true;
+    aboveThreshold = true;
     AliITSsegmentationSPD* seg =  fInfo->fSegSPD; 
     AliITSdigitSPD *d=0;
 
@@ -165,7 +165,7 @@ void ITSModule::LoadQuads()
       if (d->GetSignal() > fgSDDThreshold) {
        j = d->GetCoord1();
        i = d->GetCoord2();
-       above_treshold = true;
+       aboveThreshold = true;
        seg->DetToLocal(i,j,x,z);
        dpx = seg->Dpx(i)*0.0001;
        dpz = seg->Dpz(j)*0.0001;
@@ -192,7 +192,7 @@ void ITSModule::LoadQuads()
     for (Int_t k=0; k<ndigits; k++) {
       d=(AliITSdigitSSD*)digits->UncheckedAt(k);
       if(d->GetSignal() > fgSSDThreshold){
-       above_treshold = true;
+       aboveThreshold = true;
        j = d->GetCoord1();
        i = d->GetCoord2();
        seg->DetToLocal(i,j,x,z);
index 34cdcd9..3c2d67e 100644 (file)
 
 #pragma link C++ class Alieve::VSDCreator+;
 
-#pragma link C++ class Alieve::ITSDigitsInfo+;
-#pragma link C++ class Alieve::TPCDigitsInfo+;
-#pragma link C++ class Alieve::TPCSeg+;
-
-//================================
-// g3d/
-//================================
+// ITS
 
+#pragma link C++ class Alieve::ITSDigitsInfo+;
 #pragma link C++ class Alieve::ITSModule+;
-#pragma link C++ class Alieve::TPCSegment+;
 
-//================================
-// ged/
-//================================
+// TPC
 
-#pragma link C++ class Alieve::TPCSegmentEditor+;
+#pragma link C++ class Alieve::TPCData+;
 
-//================================
-// gl/
-//================================
+#pragma link C++ class Alieve::TPCSectorData+;
+#pragma link C++ class Alieve::TPCSectorData::PadData;
+#pragma link C++ class Alieve::TPCSectorData::PadIterator;
+#pragma link C++ class Alieve::TPCSectorData::RowIterator;
+#pragma link C++ class Alieve::TPCSectorData::SegmentInfo;
+
+#pragma link C++ class Alieve::TPCSector2D+;
+#pragma link C++ class Alieve::TPCSector2DEditor+;
+#pragma link C++ class Alieve::TPCSector2DGL+;
 
-#pragma link C++ class Alieve::TPCSegmentGL+;
+// Almost ready
+// #pragma link C++ class Alieve::TPCSector3D+;
+// #pragma link C++ class Alieve::TPCSector3DEditor+;
diff --git a/EVE/Alieve/TPCData.cxx b/EVE/Alieve/TPCData.cxx
new file mode 100644 (file)
index 0000000..47e1f87
--- /dev/null
@@ -0,0 +1,230 @@
+// $Header$
+
+#include "TPCData.h"
+
+#include <Alieve/TPCSectorData.h>
+
+#include <AliSimDigits.h>
+#include <AliTPCParam.h>
+#include <AliTPCRawStream.h>
+#include <AliTPCRawStreamOld.h>
+#include <TTree.h>
+
+using namespace Reve;
+using namespace Alieve;
+
+//______________________________________________________________________
+// TPCData
+//
+// A central manager for TPC data of an event.  Can read digits (from
+// a tree: LoadDigits()) and raw-data (via AliRawReader: LoadRaw()).
+//
+// The sector data is stored in 36 TPCSectorData objects.
+// Sectors 0 - 17: +z side, 18 - 35: -z side.
+// No separation of inner/outer segments, use row numbers for addressing.
+//
+
+ClassImp(TPCData);
+
+TPCData::TPCData() :
+  fSectors(36), fSectorBlockSize(65536),
+  fLoadThreshold(0)
+{
+  TPCSectorData::InitStatics();
+}
+
+TPCData::~TPCData()
+{
+  // !!!! delete sectors
+}
+
+/**************************************************************************/
+
+void TPCData::CreateSector(Int_t sector)
+{
+  if(fSectors[sector] == 0)
+    fSectors[sector] = new TPCSectorData(sector, fSectorBlockSize);
+}
+
+void TPCData::CreateAllSectors()
+{
+  for(Int_t s=0; s<36; ++s)
+    CreateSector(s);
+}
+
+/**************************************************************************/
+
+TPCSectorData* TPCData::GetSectorData(Int_t sector, Bool_t spawnSectors)
+{
+  if(sector < 0 || sector > 35) return 0;
+  if(fSectors[sector] == 0 && spawnSectors)
+    CreateSector(sector);
+  return fSectors[sector];
+}
+
+/**************************************************************************/
+
+void TPCData::LoadDigits(TTree* tree, Bool_t spawnSectors)
+{
+  // Load data from TTree of AliSimDigits.
+  // If spawnSectors is false only sectors that have been created previously
+  // via CreateSector() are loaded.
+  // If spawnSectors is true sectors are created if data for them is encountered.
+
+  AliSimDigits digit, *digitPtr = &digit;
+  tree->GetBranch("Segment")->SetAddress(&digitPtr);
+  
+  Int_t sector, row, pad, curPad;
+  Short_t time, signal;
+  Bool_t  inFill = kFALSE;
+  TPCSectorData* secData = 0;
+
+  Int_t numEnt = (Int_t) tree->GetEntries();
+  for (Int_t ent=0; ent<numEnt; ent++) {
+    tree->GetEntry(ent);
+    Alieve::TPCSectorData::GetParam().AdjustSectorRow(digit.GetID(), sector, row);
+    if(sector >= 36) {
+      sector -= 36;
+      row    += TPCSectorData::GetInnSeg().GetNRows();
+    }
+    secData = GetSectorData(sector, spawnSectors);
+    if(secData == 0)
+      continue;
+
+    if(digit.First() == kFALSE)
+      continue;
+    curPad = -1;
+    do {
+      pad    = digit.CurrentColumn();
+      time   = digit.CurrentRow();
+      signal = digit.CurrentDigit();
+
+      if(pad != curPad) {
+       if(inFill)
+         secData->EndPad();
+       secData->BeginPad(row, pad, kFALSE);
+       curPad = pad;
+       inFill = kTRUE;
+      }
+      if(signal > fLoadThreshold)
+       secData->RegisterData(time, signal);
+
+    } while (digit.Next());
+    if(inFill) {
+      secData->EndPad();
+      inFill = kFALSE;
+    }
+  }
+}
+
+void TPCData::LoadRaw(AliTPCRawStream& input, Bool_t spawnSectors)
+{
+  // Load data from AliTPCRawStream.
+  // If spawnSectors is false only sectors that have been created previously
+  // via CreateSector() are loaded.
+  // If spawnSectors is true sectors are created if data for them is encountered.
+
+  Int_t  sector = -1, row = -1, pad = -1, rowOffset = 0;
+  Bool_t inFill = kFALSE;
+  TPCSectorData* secData = 0;
+
+  while (input.Next()) {
+    if (input.IsNewSector()) {
+      if(inFill) {
+       secData->EndPad();
+       inFill = kFALSE;
+      }
+      sector = input.GetSector();
+      if(sector >= 36) {
+       sector -= 36;
+       rowOffset = TPCSectorData::GetInnSeg().GetNRows();
+      } else {
+       rowOffset = 0;
+      }
+      secData = GetSectorData(sector, spawnSectors);
+    }
+    if (secData == 0)
+      continue;
+
+    if (input.IsNewPad()) {
+      if(inFill) {
+       secData->EndPad();
+       inFill = kFALSE;
+      }
+      row = input.GetRow() + rowOffset;
+      pad = input.GetPad();
+
+      secData->BeginPad(row, pad, kTRUE);
+      inFill = kTRUE;
+    }
+
+    if(input.GetSignal() > fLoadThreshold)
+      secData->RegisterData(input.GetTime(), input.GetSignal());
+  }
+
+  if(inFill) {
+    secData->EndPad();
+    inFill = kFALSE;
+  }
+}
+
+void TPCData::LoadRaw(AliTPCRawStreamOld& input, Bool_t spawnSectors, Bool_t warn)
+{
+  // Load data from AliTPCRawStream.
+  // If spawnSectors is false only sectors that have been created previously
+  // via CreateSector() are loaded.
+  // If spawnSectors is true sectors are created if data for them is encountered.
+
+  static const Exc_t eH("TPCData::LoadRaw ");
+
+  Int_t  sector = -1, row = -1, pad = -1, rowOffset = 0;
+  Bool_t inFill = kFALSE;
+  TPCSectorData* secData = 0;
+
+  while (input.Next()) {
+    if (input.IsNewSector()) {
+      if(inFill) {
+       secData->EndPad();
+       inFill = kFALSE;
+      }
+      sector = input.GetSector();
+      if(sector >= 36) {
+       sector -= 36;
+       rowOffset = TPCSectorData::GetInnSeg().GetNRows();
+      } else {
+       rowOffset = 0;
+      }
+      secData = GetSectorData(sector, spawnSectors);
+    }
+    if (secData == 0)
+      continue;
+
+    if (input.IsNewPad()) {
+      if(inFill) {
+       secData->EndPad();
+       inFill = kFALSE;
+      }
+      row = input.GetRow() + rowOffset;
+      pad = input.GetPad();
+
+      if(pad >= TPCSectorData::GetNPadsInRow(row)) {
+       if(warn) {
+         Warning(eH.Data(), "pad out of range (row=%d, pad=%d, maxpad=%d).",
+                 row, pad, TPCSectorData::GetNPadsInRow(row));
+       }
+       continue;
+      }
+
+      secData->BeginPad(row, pad, kTRUE);
+      inFill = kTRUE;
+    }
+
+    if(input.GetSignal() > fLoadThreshold)
+      secData->RegisterData(input.GetTime(), input.GetSignal());
+  }
+
+  if(inFill) {
+    secData->EndPad();
+    inFill = kFALSE;
+  }
+}
diff --git a/EVE/Alieve/TPCData.h b/EVE/Alieve/TPCData.h
new file mode 100644 (file)
index 0000000..fff389a
--- /dev/null
@@ -0,0 +1,51 @@
+// $Header$
+
+#ifndef ALIEVE_TPCData_H
+#define ALIEVE_TPCData_H
+
+#include <Reve/Reve.h>
+
+#include <TObject.h>
+
+#include <vector>
+
+class TTree;
+class AliTPCRawStream;
+class AliTPCRawStreamOld;
+
+namespace Alieve {
+
+class TPCSectorData;
+
+class TPCData : public TObject, public Reve::ReferenceCount
+{
+protected:
+  std::vector<TPCSectorData*>  fSectors;
+  Int_t                        fSectorBlockSize;
+  Short_t                      fLoadThreshold;
+
+public:
+  TPCData();
+  virtual ~TPCData();
+
+  void CreateSector(Int_t sector);
+  void CreateAllSectors();
+
+  TPCSectorData* GetSectorData(Int_t sector, Bool_t spawnSectors=kFALSE);
+
+  Int_t GetSectorBlockSize()   const { return fSectorBlockSize; }
+  void  SetSectorBlockSize(Int_t bs) { fSectorBlockSize = bs; }
+
+  Short_t GetLoadThreshold()     const { return fLoadThreshold; }
+  void    SetLoadThreshold(Short_t lt) { fLoadThreshold = lt; }
+
+  void LoadDigits(TTree* tree, Bool_t spawnSectors=kTRUE);
+  void LoadRaw(AliTPCRawStream&    input, Bool_t spawnSectors=kTRUE);
+  void LoadRaw(AliTPCRawStreamOld& input, Bool_t spawnSectors=kTRUE, Bool_t warn=kFALSE);
+
+  ClassDef(TPCData, 1); // Manages TPC data for an event.
+}; // endclass TPCData
+
+}
+
+#endif
diff --git a/EVE/Alieve/TPCDigitsInfo.cxx b/EVE/Alieve/TPCDigitsInfo.cxx
deleted file mode 100644 (file)
index 1272c50..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-// $Header$
-
-//__________________________________________________________________________
-// TPCDigitsInfo
-//
-//
-
-
-#include <TFile.h>
-#include <TStopwatch.h>
-#include <Reve/TTreeTools.h>
-
-#include "TPCDigitsInfo.h"
-
-
-using namespace Reve;
-using namespace Alieve;
-using namespace std;
-
-void TPCSeg::Dump() const
-{
-  printf("TPCSeg: pw %f, pl %f, R %f, nRows %d, nMaxPads %d \n",
-        fPadWidth, fPadLength,fRlow,fNRows,fNMaxPads);
-}
-
-
-ClassImp(TPCDigitsInfo)
-
-/**************************************************************************/
-
-void TPCDigitsInfo::Init()
-{
-  fTree = 0;
-  fParameter= 0;
-}
-
-
-TPCDigitsInfo::~TPCDigitsInfo()
-{
-  delete fParameter;
-  delete fTree;
-}
-
-/**************************************************************************/
-
-void TPCDigitsInfo::SetData(AliTPCParam* par, TTree* digits)
-{ 
-  static const Exc_t eH("TPCDigitsInfo::SetData");
-
-  fParameter = par;
-  fTree = digits;
-
-  TStopwatch* sw = new  TStopwatch();
-  sw->Start();
-  fTree->LoadBaskets();
-  sw->Stop();
-  // printf("TPCDigitsInfo::SetData timer %f\n", sw->RealTime());
-  // sw->Dump();
-
-  fSegEnt.assign(72,-1);
-  AliSimDigits *digit = &fSimDigits;
-  fTree->GetBranch("Segment")->SetAddress(&digit);
-  
-  Int_t sbr=(Int_t)fTree->GetEntries();
-  for (Int_t ent=0; ent<sbr; ent++) {
-    fTree->GetEntry(ent);
-    Int_t s, row;
-    par->AdjustSectorRow(digit->GetID(),s,row);
-    // printf("found entry %d in sec %d row %d \n",ent, s, row);
-
-    if(row == 0) fSegEnt[s] = ent;
-  }
-
-
-  // read TPC Seg data
-  fInnSeg.fPadWidth   = par->GetInnerPadPitchWidth();
-  fInnSeg.fPadLength  = par->GetInnerPadPitchLength();
-  fInnSeg.fRlow       = par->GetPadRowRadiiLow(0);
-  fInnSeg.fNRows      = par->GetNRowLow();
-  fInnSeg.fNMaxPads   = par->GetNPadsLow(fInnSeg.fNRows - 1);
-
-
-  fOut1Seg.fPadWidth   = par->GetOuterPadPitchWidth();
-  fOut1Seg.fPadLength  = par->GetOuter1PadPitchLength();
-  fOut1Seg.fRlow       = par->GetPadRowRadiiUp(0);
-  fOut1Seg.fNRows      = par->GetNRowUp1();
-  fOut1Seg.fNMaxPads   = par->GetNPadsUp(fOut1Seg.fNRows-1);
-
-  fOut2Seg.fPadWidth   = par->GetOuterPadPitchWidth();
-  fOut2Seg.fPadLength  = par->GetOuter2PadPitchLength();
-  fOut2Seg.fRlow       = par->GetPadRowRadiiUp(fOut1Seg.fNRows);
-  fOut2Seg.fNRows      = par->GetNRowUp() - fOut1Seg.fNRows;
-  fOut2Seg.fNMaxPads   = par->GetNPadsUp(par->GetNRowUp()-1);
-
-
-  // set stepsize array
-  Int_t k, npads;
-  // Inn
-  k=0, npads = par->GetNPadsLow(0);
-  for (int row = 0; row < fInnSeg.fNRows ;row++ ){
-    if (par->GetNPadsLow(row) > npads){
-      npads = par->GetNPadsLow(row);
-      fInnSeg.fStepY[k]=row* fInnSeg.fPadLength +fInnSeg.fRlow;
-      k++;
-    }
-  }
-  fInnSeg.fNsteps=k;
-  // Out1 seg 
-  k=0; npads = par->GetNPadsUp(0);
-  for (int row = 0; row < fOut1Seg.fNRows ;row++ ){
-    if (par->GetNPadsUp(row) > npads){
-      npads = par->GetNPadsUp(row);
-      fOut1Seg.fStepY[k]=row* fOut1Seg.fPadLength + fOut1Seg.fRlow ;
-      k++;
-    }
-  }
-  fOut1Seg.fNsteps=k;
-  // Out2 seg
-  k=0; npads = par->GetNPadsUp(fOut1Seg.fNRows);
-  for (int row = fOut1Seg.fNRows; row < par->GetNRowUp() ;row++ ){
-    if (par->GetNPadsUp(row) > npads){
-      npads = par->GetNPadsUp(row);
-      fOut2Seg.fStepY[k]=(row - fOut1Seg.fNRows)* fOut2Seg.fPadLength + fOut2Seg.fRlow ;
-      k++;
-    }
-  }
-  fOut2Seg.fNsteps=k;
-}
-
-/**************************************************************************/
-
-void TPCDigitsInfo::Print(Option_t* ) const
-{
-  fInnSeg.Dump();
-  fOut1Seg.Dump();
-  fOut2Seg.Dump();
-}
diff --git a/EVE/Alieve/TPCDigitsInfo.h b/EVE/Alieve/TPCDigitsInfo.h
deleted file mode 100644 (file)
index a5bcc5f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// $Header$
-
-#ifndef ALIEVE_TPCDigitsInfo_H
-#define ALIEVE_TPCDigitsInfo_H
-
-#include <Reve/VSD.h>
-
-#include <vector>
-
-#include <TNamed.h>
-#include <TArrayI.h>
-#include <TTree.h>
-
-#include <AliTPCParam.h>
-#include <AliSimDigits.h>
-
-
-namespace Alieve {
-
-  class TPCSeg {
-  public:   
-    Float_t   fPadWidth, fPadLength,fRlow; // vertices data
-    Int_t     fNRows;                      // text & vertices data 
-    Int_t     fNMaxPads;                   // texture offset data
-    Float_t   fStepY[64];                  // y coord wher npads has changed
-    Int_t     fNsteps;                     // number of steps
-
-    void Dump() const;
-  };
-
-  class TPCDigitsInfo : public TNamed
-  {
-  private:
-    void Init();
-
-  protected:
-    Int_t               fRefCount;
-    TString             fDataDir;  
-    Int_t               fEvent;    
-
-  public:
-    AliSimDigits        fSimDigits;
-    AliTPCParam*        fParameter;
-    TTree*              fTree;
-    std::vector<Int_t>  fSegEnt;
-    TPCSeg              fInnSeg;   
-    TPCSeg              fOut1Seg;  
-    TPCSeg              fOut2Seg;  
-
-    TPCDigitsInfo(const Text_t* n="TPCDigitsInfo", const Text_t* t=0) :
-      TNamed(n, t) { Init(); }
-    virtual ~TPCDigitsInfo();
-
-    void SetData(AliTPCParam* par, TTree* digits);
-   
-    void IncRefCount() { ++fRefCount; }
-    void DecRefCount() { --fRefCount; if(fRefCount <= 0) delete this; }
-
-    virtual void Print(Option_t* opt="") const;
-
-    ClassDef(TPCDigitsInfo, 1);
-  }; // endclass TPCDigitsInfo
-}
-#endif
similarity index 59%
rename from EVE/Alieve/TPCSegment.cxx
rename to EVE/Alieve/TPCSector2D.cxx
index f805895..de77a89 100644 (file)
-#include "TPCSegment.h"
+#include "TPCSector2D.h"
 
+#include <Alieve/TPCData.h>
+#include <Alieve/TPCSectorData.h>
+
+#include <AliTPCParam.h>
 
 using namespace Reve;
 using namespace Alieve;
 using namespace std;
 
-ClassImp(TPCSegment)
+ClassImp(TPCSector2D);
 
 /**************************************************************************/
 
-void TPCSegment::Init()
+void TPCSector2D::Init()
 {
-  fID = 0;
-  fInfo = 0;
-
-  fTrans = false;
-
-  fRnrFrame = true;
-  fUseTexture = true;
-  fTreshold = 1;
-  fShowMax = true;
+  fTPCData   = 0;
 
+  fSectorID  = 0;
+  fShowMax   = true;
   fMinTime   = 0;
   fMaxTime   = 1;
-  fTreshold  = 5;
+  fthreshold  = 5;
   fMaxVal    = 80;
+
+  fRnrFrame   = true;
+  fUseTexture = true;
+
+  fTrans      = false;
 }
 
-TPCSegment::~TPCSegment()
+TPCSector2D::~TPCSector2D()
 {
-  if(fInfo) fInfo->DecRefCount();
+  if(fTPCData) fTPCData->DecRefCount();
 }
 
 /**************************************************************************/
 
-void TPCSegment::SetInfo(TPCDigitsInfo* info)
+void TPCSector2D::SetDataSource(TPCData* data)
 {
-  if(fInfo) fInfo->DecRefCount();
-  fInfo = info;
-  if(fInfo) fInfo->IncRefCount();
+  if(data == fTPCData) return;
+  if(fTPCData) fTPCData->DecRefCount();
+  fTPCData = data;
+  if(fTPCData) fTPCData->IncRefCount();
+  ++fRTS;
 }
 
-void TPCSegment::SetSegmentID(Int_t segment)
+void TPCSector2D::SetSectorID(Int_t segment)
 {
   if(segment < 0 ) segment = 0;
-  if(segment > 36) segment = 36;
-  fID = segment;
-  SetName(Form("TPCSegment %d", fID));
+  if(segment > 35) segment = 35;
+  fSectorID = segment;
+  SetName(Form("TPCSector2D %d", fSectorID));
   ++fRTS;
 }
 
 /**************************************************************************/
 
-void TPCSegment::ComputeBBox()
+void TPCSector2D::ComputeBBox()
 {
-  Float_t b = fInfo->fInnSeg.fRlow;
-  Float_t w = fInfo->fOut2Seg.fNMaxPads* fInfo->fOut2Seg.fPadWidth/2;
-  Float_t h = fInfo->fOut2Seg.fRlow +
-    fInfo->fOut2Seg.fNRows* fInfo->fOut2Seg.fPadLength - fInfo->fInnSeg.fRlow;
+  const TPCSectorData::SegmentInfo&  iSeg = TPCSectorData::GetInnSeg();
+  const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
 
   bbox_init();
-  fBBox[0] = -w;   fBBox[1] = w;
-  fBBox[2] =  b;   fBBox[3] = b + h;
-  fBBox[4] = -0.5; fBBox[5] = 0.5;   // Fake z-width to 1 cm.
+  Float_t w = o2Seg.GetNMaxPads()*o2Seg.GetPadWidth()/2;
+  fBBox[0] = -w;
+  fBBox[1] =  w;
+  fBBox[2] =  iSeg.GetRLow();
+  fBBox[3] =  o2Seg.GetRLow() + o2Seg.GetNRows()*o2Seg.GetPadHeight();
+  fBBox[4] = -0.5; // Fake z-width to 1 cm.
+  fBBox[5] =  0.5;
 }
 
 /**************************************************************************/
 
-void TPCSegment::SetTrans(Bool_t trans) 
+void TPCSector2D::SetTrans(Bool_t trans) 
 {
   fTrans = trans;
   if(fTrans) {
     for (Int_t k = 0; k< 16; k++)
       fMatrix[k] = 0.;
 
-    Float_t z, s, c;
-    if(fID < 18) {
-      z =  fInfo->fParameter->GetZLength();
-    } else {
-      z = -fInfo->fParameter->GetZLength();
-    } 
-  
-    // column major ii
-    fMatrix[14] = z;
-    fMatrix[15] = 1;
-
-    c = TMath::Cos((fID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2);
-    s = TMath::Sin((fID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2);
+    Float_t c = TMath::Cos((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2);
+    Float_t s = TMath::Sin((fSectorID + 0.5)*20*TMath::Pi()/180 - TMath::Pi()/2);
+    Float_t z = TPCSectorData::GetParam().GetZLength();
+    if(fSectorID >= 18) z = -z;
   
-    fMatrix[0] = -c;
-    fMatrix[1] = -s;
-    fMatrix[4] = -s;
-    fMatrix[5] =  c;
+    // column major
+    fMatrix[0]  = -c;
+    fMatrix[1]  = -s;
+    fMatrix[4]  = -s;
+    fMatrix[5]  =  c;
     fMatrix[10] = -1;
+    fMatrix[14] =  z;
+    fMatrix[15] =  1;
   }
 }
 
 /**************************************************************************/
-void TPCSegment::Paint(Option_t* )
+
+void TPCSector2D::Paint(Option_t* )
 {
   TBuffer3D buffer(TBuffer3DTypes::kGeneric);
 
@@ -106,19 +108,19 @@ void TPCSegment::Paint(Option_t* )
   buffer.fColor        = 1;
   buffer.fTransparency = 0;
   buffer.fLocalFrame   = fTrans; 
-
   if (fTrans)
     memcpy(buffer.fLocalMaster, fMatrix, 16*sizeof(Double_t));
   buffer.SetSectionsValid(TBuffer3D::kCore);
    
-  // We fill kCore on first pass and try with viewer
   Int_t reqSections = gPad->GetViewer3D()->AddObject(buffer);
   if (reqSections == TBuffer3D::kNone) {
-    // printf("TPCSegment::Paint viewer was happy with Core buff3d.\n");
+    // printf("TPCSector2D::Paint viewer was happy with Core buff3d.\n");
     return;
   }
-  printf("TPCSegment::Paint only GL supported.\n");
+
+  printf("TPCSector2D::Paint only GL supported.\n");
   return;
+
   /*
     if (reqSections & TBuffer3D::kRawSizes) {
     Int_t nbPnts = fQuads.size()*4;
diff --git a/EVE/Alieve/TPCSector2D.h b/EVE/Alieve/TPCSector2D.h
new file mode 100644 (file)
index 0000000..d1d68e8
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef ALIEVE_TPCSector2D_H
+#define ALIEVE_TPCSector2D_H
+
+#include <Reve/RenderElement.h>
+
+#include <TNamed.h> 
+#include <TBuffer3D.h>
+#include <TBuffer3DTypes.h>
+#include <TGeometry.h>
+#include <TVirtualPad.h>
+#include <TVirtualViewer3D.h>
+#include <TAtt3D.h>
+#include <TAttBBox.h>
+
+
+namespace Alieve {
+
+class TPCData;
+
+class TPCSector2DEditor;
+class TPCSector2DGL;
+
+class TPCSector2D : public TNamed, public TAtt3D, public TAttBBox, public Reve::RenderElement
+{
+  friend class TPCSector2DGL;
+  friend class TPCSector2DEditor;
+
+private:
+  void Init();
+
+protected:
+  TPCData*    fTPCData; 
+
+  // These change data representation:
+  Int_t       fSectorID; 
+  Bool_t      fShowMax;
+  Int_t       fMinTime;     
+  Int_t       fMaxTime;
+  Short_t     fthreshold;
+  Int_t       fMaxVal;
+
+  Bool_t      fRnrFrame;
+  Bool_t      fUseTexture;
+  Color_t     fFrameCol;
+
+  Double_t    fMatrix[16];
+  Bool_t      fTrans;
+  UInt_t      fRTS;       //! Rendering TimeStamp
+
+public:
+  TPCSector2D(const Text_t* n="TPCSector2D", const Text_t* t=0, Color_t col=2) : 
+    TNamed(n,t), Reve::RenderElement(fFrameCol), fFrameCol(col), fRTS(1)
+  { Init(); }
+
+  virtual ~TPCSector2D();
+
+  void SetDataSource(TPCData* data);
+  virtual void SetSectorID(Int_t id);
+
+  void SetShowMax(Bool_t sm)  { fShowMax  = sm; ++fRTS; }
+  void SetMinTime(Int_t mt)   { fMinTime  = mt; ++fRTS; }
+  void SetMaxTime(Int_t mt)   { fMaxTime  = mt; ++fRTS; }
+  void Setthreshold(Short_t t) { fthreshold =  t; ++fRTS; }
+  void SetMaxVal(Int_t mv)    { fMaxVal   = mv; ++fRTS; }
+
+  virtual void ComputeBBox();
+
+  virtual void Paint(Option_t* option="");
+
+  virtual void SetTrans(Bool_t t);
+
+  virtual Bool_t CanEditMainColor()  { return true; }
+
+  ClassDef(TPCSector2D, 1);
+}; // endclass TPCSector2D
+
+}
+
+#endif
similarity index 55%
rename from EVE/Alieve/TPCSegmentEditor.cxx
rename to EVE/Alieve/TPCSector2DEditor.cxx
index 49915d8..d0b69ba 100644 (file)
@@ -1,7 +1,7 @@
 // $Header$
 
-#include "TPCSegmentEditor.h"
-#include <Alieve/TPCSegment.h>
+#include "TPCSector2DEditor.h"
+#include <Alieve/TPCSector2D.h>
 
 #include <TVirtualPad.h>
 #include <TColor.h>
@@ -17,22 +17,22 @@ using namespace Reve;
 using namespace Alieve;
 
 //______________________________________________________________________
-// TPCSegmentEditor
+// TPCSector2DEditor
 //
 
-ClassImp(TPCSegmentEditor)
+ClassImp(TPCSector2DEditor)
 
-TPCSegmentEditor::TPCSegmentEditor(const TGWindow *p, Int_t id, Int_t width, Int_t height,
+TPCSector2DEditor::TPCSector2DEditor(const TGWindow *p, Int_t id, Int_t width, Int_t height,
                                   UInt_t options, Pixel_t back) :
   TGedFrame(p, id, width, height, options | kVerticalFrame, back)
 {
   fM = 0;
-  MakeTitle("TPCSegment");
+  MakeTitle("TPCSector2D");
 
   //!!! create the widgets here ...
 
   // Register the editor.
-  // TClass *cl = TPCSegment::Class();
+  // TClass *cl = TPCSector2D::Class();
   //  TGedElement *ge = new TGedElement;
   // ge->fGedFrame = this;
   //  ge->fCanvas = 0;
@@ -41,53 +41,53 @@ TPCSegmentEditor::TPCSegmentEditor(const TGWindow *p, Int_t id, Int_t width, Int
   fUseTexture = new TGCheckButton(this, "UseTexture");
   AddFrame(fUseTexture, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
   fUseTexture->Connect
-    ("Toggled(Bool_t)","Alieve::TPCSegmentEditor", this, "DoUseTexture()");
+    ("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoUseTexture()");
 
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    TGLabel *l = new TGLabel(f, "SegmentID:");
-    f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 15, 2, 1, 1));
+    TGLabel *l = new TGLabel(f, "SectorID:");
+    f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
 
-    fSegmentID = new TGNumberEntry(f, 0., 6, -1, 
+    fSectorID = new TGNumberEntry(f, 0., 6, -1, 
                                   TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
                                   TGNumberFormat::kNELLimitMinMax, 0, 35);
 
-    fSegmentID->GetNumberEntry()->SetToolTipText("0-18 front plate 18-36 back plate");
-    f->AddFrame(fSegmentID, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
-    fSegmentID->Associate(this);
-    fSegmentID->Connect("ValueSet(Long_t)",
-                       "Alieve::TPCSegmentEditor", this, "DoSegmentID()");                 
+    fSectorID->GetNumberEntry()->SetToolTipText("0-17 +z plate 18-35 -z plate");
+    f->AddFrame(fSectorID, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+    fSectorID->Associate(this);
+    fSectorID->Connect("ValueSet(Long_t)",
+                       "Alieve::TPCSector2DEditor", this, "DoSectorID()");                 
 
     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));  
   }
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    TGLabel *l = new TGLabel(f, "Treshold:");
-    f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 15, 2, 1, 1));
-
-    fTreshold = new TGHSlider(f, 150);
-    fTreshold->SetRange(0,10);
-    fTreshold->Associate(this);
-    f->AddFrame(fTreshold, new TGLayoutHints(kLHintsLeft, 0, 5));
-    fTreshold->Connect("PositionChanged(Int_t)",
-                      "Alieve::TPCSegmentEditor", this, "DoTreshold()");
+    fThresholdLabel = new TGLabel(f, "threshold [XXX]:");
+    f->AddFrame(fThresholdLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
+
+    fthreshold = new TGHSlider(f, 150);
+    fthreshold->SetRange(0,149);
+    fthreshold->Associate(this);
+    f->AddFrame(fthreshold, new TGLayoutHints(kLHintsLeft, 0, 5));
+    fthreshold->Connect("PositionChanged(Int_t)",
+                      "Alieve::TPCSector2DEditor", this, "Dothreshold()");
     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
   }
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    TGLabel *l = new TGLabel(f, "MaxValue:");
-    f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
+    fMaxValLabel = new TGLabel(f, "MaxValue [XXX]:");
+    f->AddFrame(fMaxValLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 2, 1, 1));
     fMaxVal = new TGHSlider(f, 150);
-    fMaxVal->SetRange(0,100);
+    fMaxVal->SetRange(0,299);
     fMaxVal->Associate(this);
     f->AddFrame(fMaxVal, new TGLayoutHints(kLHintsLeft, 0, 5));
     fMaxVal->Connect("PositionChanged(Int_t)",
-                    "Alieve::TPCSegmentEditor", this, "DoMaxVal()");
+                    "Alieve::TPCSector2DEditor", this, "DoMaxVal()");
     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
   }
   fShowMax = new TGCheckButton(this, "ShowMax");
   AddFrame(fShowMax, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
-  fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSegmentEditor", this, "DoShowMax()");
+  fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoShowMax()");
 
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
@@ -98,29 +98,29 @@ TPCSegmentEditor::TPCSegmentEditor(const TGWindow *p, Int_t id, Int_t width, Int
     fTime->SetRange(0, 500);
     fTime->Resize(160, 20);
     f->AddFrame(fTime);//, new TGLayoutHints(kLHintsLeft, 0, 5));
-    fTime->Connect("PositionChanged()", "Alieve::TPCSegmentEditor",
+    fTime->Connect("PositionChanged()", "Alieve::TPCSector2DEditor",
                   this, "DoTime()");
     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
   }
   // What is this crap?
-  TClass *cl = TPCSegmentEditor::Class();
+  TClass *cl = TPCSector2DEditor::Class();
   TGedElement *ge = new TGedElement;
   ge->fGedFrame = this;
   ge->fCanvas = 0;
   cl->GetEditorList()->Add(ge);
 }
 
-TPCSegmentEditor::~TPCSegmentEditor()
+TPCSector2DEditor::~TPCSector2DEditor()
 {}
 
 /**************************************************************************/
 
-void TPCSegmentEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
+void TPCSector2DEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
 {
   fModel = 0;
   fPad   = 0;
 
-  if (!obj || !obj->InheritsFrom(TPCSegment::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
+  if (!obj || !obj->InheritsFrom(TPCSector2D::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
     SetActive(kFALSE);
     return;
   }
@@ -128,55 +128,57 @@ void TPCSegmentEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
   fModel = obj;
   fPad   = pad;
 
-  fM = dynamic_cast<TPCSegment*>(fModel);
+  fM = dynamic_cast<TPCSector2D*>(fModel);
 
   fUseTexture->SetState(fM->fUseTexture ? kButtonDown : kButtonUp);
-  fSegmentID->SetNumber(fM->fID);
-  fTreshold->SetPosition(fM->fTreshold);//(fTreshold->GetMaxPosition()- fTreshold->GetMinPosition() ));
+  fSectorID->SetNumber(fM->fSectorID);
+  fThresholdLabel->SetText(Form("threshold [%3d]:", fM->fthreshold));
+  fthreshold->SetPosition(fM->fthreshold);
 
+  fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
   fMaxVal->SetPosition(fM->fMaxVal);
   fTime->SetPosition(fM->fMinTime, fM->fMaxTime);
 
   fShowMax->SetState(fM->fShowMax ? kButtonDown : kButtonUp);
-  //  fTime->SetPosition(fM->fMaxTime);
+
   SetActive();
 }
 
 /**************************************************************************/
 
-void TPCSegmentEditor::DoUseTexture()
+void TPCSector2DEditor::DoUseTexture()
 {
   fM->fUseTexture = fUseTexture->IsOn();
   Update();
 }
 
-void TPCSegmentEditor::DoSegmentID()
+void TPCSector2DEditor::DoSectorID()
 {
-  fM->SetSegmentID((Int_t) fSegmentID->GetNumber());
+  fM->SetSectorID((Int_t) fSectorID->GetNumber());
   Update();
 }
 
-void TPCSegmentEditor::DoTreshold()
+void TPCSector2DEditor::Dothreshold()
 {
-  fM->SetTreshold((Short_t) fTreshold->GetPosition());
-  printf("DoTreshold %d \n",  fM->fTreshold);
+  fM->Setthreshold((Short_t) fthreshold->GetPosition());
+  fThresholdLabel->SetText(Form("threshold [%3d]:", fM->fthreshold));
   Update();
 }
 
-void TPCSegmentEditor::DoMaxVal()
+void TPCSector2DEditor::DoMaxVal()
 {
   fM->SetMaxVal((Int_t) fMaxVal->GetPosition());
-  printf("DoMaxVal %d \n",fM->fMaxVal);
+  fMaxValLabel->SetText(Form("MaxValue [%3d]:", fM->fMaxVal));
   Update();
 }
 
-void TPCSegmentEditor::DoShowMax()
+void TPCSector2DEditor::DoShowMax()
 {
   fM->SetShowMax(fShowMax->IsOn());
   Update();
 }
 
-void TPCSegmentEditor::DoTime()
+void TPCSector2DEditor::DoTime()
 { 
   Double_t min = fTime->GetMinPosition(), max = fTime->GetMaxPosition();
   printf("hslidor min=%f max=%f\n", min, max);
diff --git a/EVE/Alieve/TPCSector2DEditor.h b/EVE/Alieve/TPCSector2DEditor.h
new file mode 100644 (file)
index 0000000..dfca7a2
--- /dev/null
@@ -0,0 +1,58 @@
+// $Header$
+
+#ifndef ALIEVE_TPCSector2DEditor_H
+#define ALIEVE_TPCSector2DEditor_H
+
+#include <TGedFrame.h>
+
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+class TGDoubleHSlider;
+class TGHSlider;
+
+namespace Alieve {
+
+class TPCSector2D;
+
+class TPCSector2DEditor : public TGedFrame
+{
+protected:
+  TPCSector2D* fM; // fModel dynamic-casted to TPCSector2DEditor
+
+  TGCheckButton*   fUseTexture;
+
+  TGNumberEntry*   fSectorID;
+
+  TGLabel*         fThresholdLabel;
+  TGLabel*         fMaxValLabel;
+  TGHSlider*       fthreshold;
+  TGHSlider*       fMaxVal;
+
+  TGCheckButton*   fShowMax;
+
+  TGDoubleHSlider* fTime;
+
+public:
+  TPCSector2DEditor(const TGWindow* p, Int_t id, Int_t width = 170, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground());
+  ~TPCSector2DEditor();
+
+  virtual void SetModel(TVirtualPad* pad, TObject* obj, Int_t event);
+  virtual Bool_t CanEditMainColor()  { return true; }
+
+  // void DoXYZZ();
+  void DoUseTexture();
+
+  void DoSectorID();
+
+  void Dothreshold();
+  void DoMaxVal();
+  void DoShowMax();
+  void DoTime();
+  ClassDef(TPCSector2DEditor, 0); // Editor for TPCSector2D
+}; // endclass TPCSector2DEditor
+
+}
+
+#endif
diff --git a/EVE/Alieve/TPCSector2DGL.cxx b/EVE/Alieve/TPCSector2DGL.cxx
new file mode 100644 (file)
index 0000000..edf8a9d
--- /dev/null
@@ -0,0 +1,350 @@
+// $Header$
+
+#include "TPCSector2DGL.h"
+
+#include <Alieve/TPCData.h>
+
+#include <TStyle.h>
+#include <TColor.h>
+#include <TStopwatch.h>
+
+#include <GL/gl.h>
+
+using namespace Reve;
+using namespace Alieve;
+using namespace std;
+
+  // This can be optimized to non-pow-2 values once everybody has GL 1.4.
+
+const Int_t TPCSector2DGL::fgkTextureWidth    = 256;
+const Int_t TPCSector2DGL::fgkTextureHeight   = 128;
+const Int_t TPCSector2DGL::fgkTextureByteSize = 4*256*128;
+
+/**************************************************************************/
+
+TPCSector2DGL::TPCSector2DGL() : TGLObject()
+{
+  fSector     = 0;
+  fSectorData = 0;
+
+  fImage   = 0;
+  fTexture = 0;
+  fRTS     = 0;
+}
+
+TPCSector2DGL::~TPCSector2DGL()
+{
+  if(fImage)   delete fImage;
+  if(fTexture) glDeleteTextures(1, &fTexture);
+}
+
+/**************************************************************************/
+
+Bool_t TPCSector2DGL::SetModel(TObject* obj)
+{
+  if (set_model(obj, "Alieve::TPCSector2D")) {
+    fSector = (TPCSector2D*) fExternalObj;
+    return true;
+  }
+  return false;
+}
+
+void TPCSector2DGL::SetBBox()
+{
+  set_axis_aligned_bbox(((TPCSector2D*)fExternalObj)->AssertBBox());
+}
+
+/**************************************************************************/
+
+void TPCSector2DGL::SetCol(Float_t z, UChar_t* pixel) const
+{
+  Int_t n_col = gStyle->GetNumberOfColors();
+
+  Int_t ci = gStyle->GetColorPalette
+    (TMath::Min(n_col - 1,
+                Int_t((n_col*(z - fSector->fthreshold))/(fSector->fMaxVal - fSector->fthreshold))));
+
+  TColor* c = gROOT->GetColor(ci);
+
+  if(c) {
+    //    UChar_t *x = (UChar_t*) &c;
+    pixel[0] = (UChar_t)(255*c->GetRed());
+    pixel[1] = (UChar_t)(255*c->GetGreen());
+    pixel[2] = (UChar_t)(255*c->GetBlue());
+    pixel[3] = 255;
+  }
+}
+
+/**************************************************************************/
+
+void TPCSector2DGL::DirectDraw(const TGLDrawFlags& /*flags*/) const
+{
+  // Actual GL drawing.
+
+  // printf("TPCSector2DGL::DirectDraw \n");
+
+  if(fSector->fTPCData == 0)
+    fSectorData = 0;
+  else
+    fSectorData = fSector->fTPCData->GetSectorData(fSector->fSectorID);
+
+  if(fRTS < fSector->fRTS && fSectorData != 0) {
+    CreateTexture();
+    fRTS = fSector->fRTS;
+  }
+
+  glPushAttrib(GL_CURRENT_BIT      | GL_DEPTH_BUFFER_BIT |
+               GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT       | GL_POLYGON_BIT);
+
+  glDisable(GL_LIGHTING);
+  glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+  glEnable(GL_COLOR_MATERIAL);
+  glDisable(GL_CULL_FACE);
+
+  // Display digits
+  if(fSectorData != 0) {
+
+    const TPCSectorData::SegmentInfo&  iSeg = TPCSectorData::GetInnSeg();
+    const TPCSectorData::SegmentInfo& o1Seg = TPCSectorData::GetOut1Seg();
+    const TPCSectorData::SegmentInfo& o2Seg = TPCSectorData::GetOut2Seg();
+
+    if(fSector->fUseTexture) {
+      //texture
+      glEnable(GL_BLEND);
+      glDepthMask(GL_FALSE);
+      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+      glShadeModel(GL_FLAT);
+
+      glBindTexture  (GL_TEXTURE_2D, fTexture);
+
+      glPolygonOffset(2,2);
+      glEnable(GL_POLYGON_OFFSET_FILL);
+
+      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+      glBindTexture(GL_TEXTURE_2D, fTexture);
+      glEnable(GL_TEXTURE_2D);
+
+      DisplayTexture(iSeg.GetPadWidth(),  iSeg.GetPadHeight(),  iSeg.GetRLow(),
+                    iSeg.GetNMaxPads(),  iSeg.GetNRows(),
+                    0,                   0);
+      DisplayTexture(o1Seg.GetPadWidth(), o1Seg.GetPadHeight(), o1Seg.GetRLow(),
+                    o1Seg.GetNMaxPads(), o1Seg.GetNRows(),
+                    iSeg.GetNMaxPads(),  0);
+      DisplayTexture(o2Seg.GetPadWidth(), o2Seg.GetPadHeight(), o2Seg.GetRLow(),
+                    o2Seg.GetNMaxPads(), o2Seg.GetNRows(),
+                    0,                   o1Seg.GetNRows());
+
+      glDisable(GL_TEXTURE_2D);
+    } else {
+      DisplayQuads(iSeg.GetPadWidth(),  iSeg.GetPadHeight(),  iSeg.GetRLow(),
+                  iSeg.GetNMaxPads(),  iSeg.GetNRows(),
+                  0,                   0);
+      DisplayQuads(o1Seg.GetPadWidth(), o1Seg.GetPadHeight(), o1Seg.GetRLow(),
+                  o1Seg.GetNMaxPads(), o1Seg.GetNRows(),
+                  iSeg.GetNMaxPads(),    0);
+      DisplayQuads(o2Seg.GetPadWidth(), o2Seg.GetPadHeight(), o2Seg.GetRLow(),
+                  o2Seg.GetNMaxPads(), o2Seg.GetNRows(),
+                  0,                   o1Seg.GetNRows());
+    }
+  }
+
+  // Display frame
+  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+  DisplayFrame();
+
+  glPopAttrib();
+}
+
+/**************************************************************************/
+// Data import
+/**************************************************************************/
+
+void TPCSector2DGL::LoadPadrow(TPCSectorData::RowIterator& iter,
+                              Int_t row, Int_t col_off) const
+{
+  Int_t    pad_var;
+  Int_t    time, val;   
+
+  Int_t    min_time = fSector->fMinTime;
+  Int_t    max_time = fSector->fMaxTime;
+  Bool_t   half_border_time = ((fSector->fMaxTime - fSector->fMinTime) % 2 == 0);
+
+  UChar_t* img_pos = GetRowCol(row, col_off);
+  while (iter.NextPad()) {
+    pad_var = 0; 
+
+    while (iter.Next()) {
+      time = iter.Time();
+      val  = iter.Signal();
+
+      if(fSector->fShowMax) {
+        if(val > pad_var) {
+          pad_var = val;
+        }
+      } else {
+        // Integrate int max_val.
+        if(time >= min_time && time <= max_time) {
+          if(half_border_time && (time == min_time || time == max_time))
+            pad_var += val/2;
+          else
+            pad_var += val;
+        }
+      }
+    }
+
+    pad_var = TMath::Min(pad_var, fSector->fMaxVal);
+    if(pad_var > fSector->fthreshold)
+      SetCol(pad_var, img_pos);
+    img_pos += 4;
+  }
+}
+
+/**************************************************************************/
+
+void TPCSector2DGL::CreateTexture() const
+{
+  if (fImage == 0 ) {
+    fImage = new UChar_t[fgkTextureByteSize];
+    glGenTextures(1, &fTexture);
+  }
+  memset(fImage, 0, fgkTextureByteSize);
+
+  Int_t rowOff[3], colOff[3];
+  rowOff[0] = 0; rowOff[1] = rowOff[2] = -TPCSectorData::GetSeg(1).GetFirstRow();
+  colOff[0] = colOff[2] = 0; colOff[1] =  TPCSectorData::GetSeg(0).GetNMaxPads();
+
+  // Loop over 3 main segments
+  for (Int_t sId = 0; sId <= 2; ++sId) {
+    const TPCSectorData::SegmentInfo& sInfo = TPCSectorData::GetSeg(sId);
+    for (Int_t row=sInfo.GetFirstRow(); row<=sInfo.GetLastRow(); ++row) {
+      TPCSectorData::RowIterator i = fSectorData->MakeRowIterator(row);
+      Int_t offset = (sInfo.GetNMaxPads() - TPCSectorData::GetNPadsInRow(row))/2;
+      LoadPadrow(i, row + rowOff[sId], offset + colOff[sId]);
+    }
+  }
+
+  glBindTexture  (GL_TEXTURE_2D, fTexture);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+  // glTexEnvf      (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,   GL_MODULATE); // Lightning is off anyway.
+  glTexImage2D   (GL_TEXTURE_2D, 0, GL_RGBA, fgkTextureWidth, fgkTextureHeight,
+                  0, GL_RGBA, GL_UNSIGNED_BYTE, fImage);
+
+}
+
+/**************************************************************************/
+// Data display
+/**************************************************************************/
+
+void TPCSector2DGL::DisplayTexture(Float_t padW,     Float_t padH, Float_t startR,
+                                   Int_t numMaxPads, Int_t numRows, 
+                                   Int_t startCol,   Int_t startRow) const
+{
+  Float_t w  = numMaxPads*padW/2;
+  Float_t u1 = (Float_t) startCol / fgkTextureWidth;
+  Float_t v1 = (Float_t) startRow / fgkTextureHeight;
+  Float_t u2 = u1 + (Float_t) numMaxPads / fgkTextureWidth;
+  Float_t v2 = v1 + (Float_t) numRows    / fgkTextureHeight;
+
+  glBegin(GL_QUADS);  
+  glTexCoord2f(u1, v1);  glVertex2f(-w, startR);
+  glTexCoord2f(u1, v2);  glVertex2f(-w, startR + numRows*padH);
+  glTexCoord2f(u2, v2);  glVertex2f( w, startR + numRows*padH);
+  glTexCoord2f(u2, v1);  glVertex2f( w, startR);
+  glEnd();
+}
+
+/**************************************************************************/
+
+void TPCSector2DGL::DisplayQuads(Float_t padW,     Float_t padH, Float_t startR,
+                                 Int_t numMaxPads, Int_t numRows, 
+                                 Int_t startCol,   Int_t startRow) const
+{
+  UChar_t *pix;
+  Float_t y_d, y_u;
+  Float_t x_off, x;
+
+  glBegin(GL_QUADS);
+  for (Int_t row=0; row<numRows; row++) {
+    y_d = startR + row*padH;
+    y_u = y_d + padH;
+    x_off = -numMaxPads*padW/2;
+    pix = GetRowCol(row + startRow, startCol);
+    for (Int_t pad=0; pad<numMaxPads; pad++, pix+=4) {
+      x = x_off + pad*padW;
+      if (pix[3] != 0) {
+        glColor4ubv(pix);
+        glVertex2f(x+padW, y_d);
+        glVertex2f(x,      y_d);
+        glVertex2f(x,      y_u);
+        glVertex2f(x+padW, y_u);
+      }
+    }
+  }
+  glEnd();
+}
+
+/**************************************************************************/
+// Frame drawing
+/**************************************************************************/
+
+void TPCSector2DGL::TraceStepsUp(const TPCSectorData::SegmentInfo& s)
+{
+  Float_t x = -(s.GetNMaxPads()*1.0/2 - s.GetNYSteps())*s.GetPadWidth();
+  Float_t y  = s.GetRLow();
+  glVertex2f(x, y);
+  for (Int_t i=0; i<s.GetNYSteps(); ++i) {
+    y = s.GetYStep(i);
+    glVertex2f(x, y);
+    x -= s.GetPadWidth();
+    glVertex2f(x, y);
+  }
+  y =  s.GetRLow() + s.GetNRows()*s.GetPadHeight();
+  glVertex2f(-s.GetNMaxPads()*s.GetPadWidth()/2, y);
+}
+
+void TPCSector2DGL::TraceStepsDown(const TPCSectorData::SegmentInfo& s) 
+{
+  Float_t x = s.GetNMaxPads()*s.GetPadWidth()/2;
+  Float_t y = s.GetRLow() + s.GetNRows()*s.GetPadHeight();
+  glVertex2f(x, y);
+  for (Int_t i=s.GetNYSteps() - 1; i>=0; --i) {
+    y =  s.GetYStep(i);
+    glVertex2f(x, y);
+    x -= s.GetPadWidth();
+    glVertex2f(x, y);
+  }
+  y = s.GetRLow();
+  glVertex2f((0.5*s.GetNMaxPads() - s.GetNYSteps())*s.GetPadWidth(), y);
+}
+
+void TPCSector2DGL::DisplayFrame() const
+{
+  TColor* c = gROOT->GetColor(fSector->fFrameCol);
+  if(c == 0) return; 
+
+  // x[0] = (UChar_t)(255*c->GetRed());  x[1] = (UChar_t)(255*c->GetGreen());
+  // x[2] = (UChar_t)(255*c->GetBlue()); x[3] = 255;
+
+  glColor3ub((UChar_t)(255*c->GetRed()), 
+             (UChar_t)(255*c->GetGreen()),
+             (UChar_t)(255*c->GetBlue()));
+
+  glBegin(GL_LINE_LOOP);
+  TraceStepsUp  (TPCSectorData::GetInnSeg());
+  TraceStepsDown(TPCSectorData::GetInnSeg());
+  glEnd();
+
+  glBegin(GL_LINE_LOOP);
+  TraceStepsUp  (TPCSectorData::GetOut1Seg());
+  TraceStepsDown(TPCSectorData::GetOut1Seg());
+  glEnd();
+
+  glBegin(GL_LINE_STRIP);
+  TraceStepsUp  (TPCSectorData::GetOut2Seg());
+  TraceStepsDown(TPCSectorData::GetOut2Seg());
+  glEnd();
+}
diff --git a/EVE/Alieve/TPCSector2DGL.h b/EVE/Alieve/TPCSector2DGL.h
new file mode 100644 (file)
index 0000000..8f75a9d
--- /dev/null
@@ -0,0 +1,66 @@
+// $Header$
+
+#ifndef ALIEVE_TPCSector2DGL_H
+#define ALIEVE_TPCSector2DGL_H
+
+#include <TGLObject.h>
+
+#include <Alieve/TPCSector2D.h>
+#include <Alieve/TPCSectorData.h>
+
+
+namespace Alieve {
+
+class TPCSector2DGL : public TGLObject
+{
+protected:
+  virtual void DirectDraw(const TGLDrawFlags & flags) const;
+
+  void LoadPadrow(TPCSectorData::RowIterator& iter, Int_t row, Int_t off) const;
+  void CreateTexture() const;
+
+  void DisplayTexture(Float_t padW,     Float_t padH, Float_t startR,
+                      Int_t numMaxPads, Int_t numRows,
+                      Int_t startCol,   Int_t startRow) const;
+  void DisplayQuads  (Float_t padW,     Float_t padH, Float_t startR,
+                     Int_t numMaxPads, Int_t numRows,
+                     Int_t startCol,   Int_t startRow) const;
+  void DisplayFrame  () const;
+
+  UChar_t* GetRowCol(Int_t row, Int_t col) const;
+
+  TPCSector2D*                 fSector;
+  mutable TPCSectorData*       fSectorData;
+
+  mutable UChar_t*             fImage;
+  mutable UInt_t               fTexture;
+  mutable UInt_t               fRTS;
+public:
+  TPCSector2DGL();
+  virtual ~TPCSector2DGL();
+
+  virtual Bool_t SetModel(TObject* obj); 
+  virtual void   SetBBox();
+
+  void SetCol(Float_t z, UChar_t* pixel) const;
+
+  static void TraceStepsUp  (const TPCSectorData::SegmentInfo& s);
+  static void TraceStepsDown(const TPCSectorData::SegmentInfo& s);
+
+  static const Int_t fgkTextureWidth;
+  static const Int_t fgkTextureHeight;
+  static const Int_t fgkTextureByteSize;
+
+}; // endclass TPCSector2D_GL_Rnr
+  
+
+inline UChar_t* TPCSector2DGL::GetRowCol(Int_t row, Int_t col) const
+{
+  return fImage + 4*(row*fgkTextureWidth + col);
+}
+
+
+}
+
+#endif
diff --git a/EVE/Alieve/TPCSectorData.cxx b/EVE/Alieve/TPCSectorData.cxx
new file mode 100644 (file)
index 0000000..06c3adf
--- /dev/null
@@ -0,0 +1,402 @@
+// $Header$
+
+#include "TPCSectorData.h"
+#include <AliTPCParamSR.h>
+
+#include <string.h>
+
+//______________________________________________________________________
+// TPCSectorData
+//
+// Stores data from a fiven TPC sector.
+//
+// Row addresses grow linearly by radius, there is no separation on
+// inner/outer segments. The SegmentInfo objects can be used to get
+// information about low-level segments.
+//
+// A lot of TPC-sector information is stored as static data.
+//
+// For accessing data, see for example TPCSector2DGL::CreateTexture()
+// and LoadPadrow().
+//
+
+using namespace Reve;
+using namespace Alieve;
+
+ClassImp(TPCSectorData);
+
+AliTPCParam* TPCSectorData::fgParam    = 0;
+Int_t        TPCSectorData::fgNAllRows = 0;
+Int_t        TPCSectorData::fgNAllPads = 0;
+Int_t*       TPCSectorData::fgRowBegs  = 0;
+
+TPCSectorData::SegmentInfo TPCSectorData::fgInnSeg;
+TPCSectorData::SegmentInfo TPCSectorData::fgOut1Seg;
+TPCSectorData::SegmentInfo TPCSectorData::fgOut2Seg;
+
+TPCSectorData::SegmentInfo* TPCSectorData::fgSegInfoPtrs[3] = {0};
+
+/**************************************************************************/
+
+void TPCSectorData::InitStatics()
+{
+  if(fgParam != 0) return;
+
+  fgParam    = new AliTPCParamSR;
+  fgNAllRows = fgParam->GetNRowLow() + fgParam->GetNRowUp();
+  fgNAllPads = 0;
+  fgRowBegs  = new Int_t[fgNAllRows + 1];
+
+  Int_t row = 0;
+  for(Int_t i=0; i<fgParam->GetNRowLow(); ++i, ++row) {
+    fgRowBegs[row] = fgNAllPads;
+    fgNAllPads += fgParam->GetNPadsLow(i);
+  }
+  for(Int_t i=0; i<fgParam->GetNRowUp(); ++i, ++row) {
+    fgRowBegs[row] = fgNAllPads;
+    fgNAllPads += fgParam->GetNPadsUp(i);
+  }
+  fgRowBegs[fgNAllRows] = fgNAllPads;
+
+
+  // Fill SegmentInfos, used by rendering classes.
+
+  // General paramameters
+  fgInnSeg.fPadWidth   = fgParam->GetInnerPadPitchWidth();
+  fgInnSeg.fPadHeight  = fgParam->GetInnerPadPitchLength();
+  fgInnSeg.fRLow       = fgParam->GetPadRowRadiiLow(0);
+  fgInnSeg.fNRows      = fgParam->GetNRowLow();
+  fgInnSeg.fFirstRow   = 0;
+  fgInnSeg.fLastRow    = fgInnSeg.fNRows - 1;
+  fgInnSeg.fNMaxPads   = fgParam->GetNPadsLow(fgInnSeg.fNRows - 1);
+  fgSegInfoPtrs[0]     = &fgInnSeg;
+
+  fgOut1Seg.fPadWidth  = fgParam->GetOuterPadPitchWidth();
+  fgOut1Seg.fPadHeight = fgParam->GetOuter1PadPitchLength();
+  fgOut1Seg.fRLow      = fgParam->GetPadRowRadiiUp(0);
+  fgOut1Seg.fNRows     = fgParam->GetNRowUp1();
+  fgOut1Seg.fFirstRow  = fgInnSeg.fNRows;
+  fgOut1Seg.fLastRow   = fgOut1Seg.fFirstRow + fgOut1Seg.fNRows - 1;
+  fgOut1Seg.fNMaxPads  = fgParam->GetNPadsUp(fgOut1Seg.fNRows - 1);
+  fgSegInfoPtrs[1]     = &fgOut1Seg;
+  fgOut2Seg.fPadWidth  = fgParam->GetOuterPadPitchWidth();
+  fgOut2Seg.fPadHeight = fgParam->GetOuter2PadPitchLength();
+  fgOut2Seg.fRLow      = fgParam->GetPadRowRadiiUp(fgOut1Seg.fNRows);
+  fgOut2Seg.fNRows     = fgParam->GetNRowUp() - fgOut1Seg.fNRows;
+  fgOut2Seg.fFirstRow  = fgOut1Seg.fLastRow + 1;
+  fgOut2Seg.fLastRow   = fgOut2Seg.fFirstRow + fgOut2Seg.fNRows - 1;
+  fgOut2Seg.fNMaxPads  = fgParam->GetNPadsUp(fgParam->GetNRowUp() - 1);
+  fgSegInfoPtrs[2]     = &fgOut2Seg;
+
+  // Set stepsize array
+  Int_t k, npads;
+  // Inn
+  k=0, npads = fgParam->GetNPadsLow(0);
+  for (int row = 0; row < fgInnSeg.fNRows; ++row) {
+    if (fgParam->GetNPadsLow(row) > npads) {
+      npads = fgParam->GetNPadsLow(row);
+      fgInnSeg.fYStep[k] = row*fgInnSeg.fPadHeight + fgInnSeg.fRLow;
+      k++;
+    }
+  }
+  fgInnSeg.fNYSteps = k;
+  // Out1 seg 
+  k=0; npads = fgParam->GetNPadsUp(0);
+  for (int row = 0; row < fgOut1Seg.fNRows; ++row) {
+    if (fgParam->GetNPadsUp(row) > npads) {
+      npads = fgParam->GetNPadsUp(row);
+      fgOut1Seg.fYStep[k] = row*fgOut1Seg.fPadHeight + fgOut1Seg.fRLow ;
+      k++;
+    }
+  }
+  fgOut1Seg.fNYSteps = k;
+  // Out2 seg
+  k=0; npads = fgParam->GetNPadsUp(fgOut1Seg.fNRows);
+  for (int row = fgOut1Seg.fNRows; row < fgParam->GetNRowUp() ;row++ ) {
+    if (fgParam->GetNPadsUp(row) > npads) {
+      npads = fgParam->GetNPadsUp(row);
+      fgOut2Seg.fYStep[k] = (row - fgOut1Seg.fNRows)*fgOut2Seg.fPadHeight + fgOut2Seg.fRLow ;
+      k++;
+    }
+  }
+  fgOut2Seg.fNYSteps = k;
+}
+
+Int_t TPCSectorData::GetNPadsInRow(Int_t row)
+{
+  if(row < 0 || row >= fgNAllRows) return 0;
+  return fgRowBegs[row + 1] - fgRowBegs[row];
+}
+
+const TPCSectorData::SegmentInfo& TPCSectorData::GetSeg(Int_t seg)
+{
+  static const SegmentInfo null;
+
+  if(seg < 0 || seg > 2)
+    return null;
+  else
+    return *fgSegInfoPtrs[seg];
+}
+
+/**************************************************************************/
+// True member functions start here.
+/**************************************************************************/
+
+void TPCSectorData::NewBlock()
+{
+  fBlocks.push_back(new Short_t[fBlockSize]);
+  fBlockPos = 0;
+}
+
+/**************************************************************************/
+
+TPCSectorData::TPCSectorData(Int_t sector, Int_t bsize) :
+  fSectorID(sector), fNPadsFilled(0),
+  fBlockSize(bsize), fBlockPos(0),
+  fCurrentRow(0), fCurrentPad(0), fCurrentPos(0)
+{
+  if(fgParam == 0) InitStatics();
+
+  fPads.assign(fgNAllPads, PadData());
+  fBlocks.reserve(16);
+  fBlockPos = fBlockSize; // Enforce creation of a new block.
+}
+
+
+TPCSectorData::~TPCSectorData()
+{
+  for(std::vector<Short_t*>::iterator b=fBlocks.begin(); b!=fBlocks.end(); ++b)
+    delete [] *b;
+}
+
+/**************************************************************************/
+
+void TPCSectorData::Print(Option_t* /*opt*/) const
+{
+  printf("TPCSectorData sector=%d, NPadsFilled=%d, NBlocks=%d, BlockPos=%d\n",
+        fSectorID, fNPadsFilled, fBlocks.size(), fBlockPos);
+}
+
+/**************************************************************************/
+
+void TPCSectorData::BeginPad(Int_t row, Int_t pad, Bool_t reverseTime)
+{
+  fCurrentRow = row;
+  fCurrentPad = pad;
+  if(reverseTime) {
+    fCurrentPos  = 2046;
+    fCurrentStep = -2;
+  } else {
+    fCurrentPos  = 0;
+    fCurrentStep = 2;
+  }
+}
+
+void TPCSectorData::EndPad()
+{
+  Short_t *beg, *end;
+  if(fCurrentStep > 0) {
+    beg = fPadBuffer;
+    end = fPadBuffer + fCurrentPos;
+  } else {
+    beg = fPadBuffer + fCurrentPos + 2;
+    end = fPadBuffer + 2048;
+  }
+  Short_t* wpos = beg;
+  Short_t* rpos = beg;
+
+  // Compress pad buffer
+  while(rpos < end) {
+    Short_t* spos = rpos;
+    Short_t  t    = spos[0];
+    while(true) {
+      rpos += 2;
+      if(rpos >= end || *rpos > t + 1 || t == 0)
+       break;
+      ++t;
+    }
+    Short_t n = t - spos[0] + 1;
+    if(n == 1) {
+      wpos[0] = -spos[0];
+      wpos[1] =  spos[1];
+      wpos += 2;
+    } else {
+      wpos[0] = spos[0];
+      wpos[2] = spos[1];
+      wpos[1] = n;
+      wpos += 3; spos += 3;
+      while(--n) {
+       *wpos = *spos;
+       ++wpos; spos += 2;
+      }
+    }
+  }
+
+  // Copy buffer to storage, set PadData
+  if(wpos > beg) {
+    Short_t len = wpos - beg;
+    if(len > fBlockSize - fBlockPos)
+      NewBlock();
+    Short_t *dest = fBlocks.back() + fBlockPos;
+    memcpy(dest, beg, len*sizeof(Short_t));
+    fBlockPos += len;
+
+    PadData& pad = fPads[PadIndex(fCurrentRow, fCurrentPad)];
+    pad.SetDataLength(dest, len);
+  }
+
+  ++fNPadsFilled;
+}
+
+/**************************************************************************/
+
+const TPCSectorData::PadData& TPCSectorData::GetPadData(Int_t padAddr)
+{
+  static const PadData null;
+
+  if(padAddr < 0 || padAddr >= fgNAllPads) return null;
+  return fPads[padAddr];
+}
+
+const TPCSectorData::PadData& TPCSectorData::GetPadData(Int_t row, Int_t pad)
+{
+  static const PadData null;
+
+  Int_t np = GetNPadsInRow(row);
+  if(np == 0 || pad < 0 || pad >= np) return null;
+  return GetPadData(fgRowBegs[row] + pad);
+}
+
+TPCSectorData::PadIterator TPCSectorData::MakePadIterator(Int_t padAddr, Short_t thr)
+{
+  return PadIterator(GetPadData(padAddr), thr);
+}
+
+TPCSectorData::PadIterator TPCSectorData::MakePadIterator(Int_t row, Int_t pad, Short_t thr)
+{
+  return PadIterator(GetPadData(row, pad), thr);
+}
+
+TPCSectorData::RowIterator TPCSectorData::MakeRowIterator(Int_t row, Short_t thr)
+{
+  Short_t npads = GetNPadsInRow(row);
+  if(npads > 0)
+    return RowIterator(&fPads[fgRowBegs[row]], npads, thr);
+  else
+    return RowIterator(0, 0);
+}
+
+/**************************************************************************/
+// TPCSectorData::PadData
+/**************************************************************************/
+
+void TPCSectorData::PadData::Print(Option_t* /*opt*/)
+{
+  printf("addr=%p, len=%hd>\n", (void*)fData, fLength);
+  for(Int_t i=0; i<fLength; ++i)
+    printf("  %3d %hd\n", i, fData[i]);
+}
+
+/**************************************************************************/
+// TPCSectorData::PadIterator
+/**************************************************************************/
+
+Bool_t TPCSectorData::PadIterator::Next()
+{
+  if(fPos >= fEnd) return kFALSE;
+  if(fNChunk > 0) {
+    ++fTime;
+    --fNChunk;
+    fSignal = *fPos; ++fPos;
+  } else {
+    fTime = fPos[0];
+    if(fTime <= 0) {
+      fTime   = -fTime;
+      fSignal = fPos[1];
+      fPos += 2;
+    } else {
+      fNChunk = fPos[1] - 1;
+      fSignal = fPos[2];
+      fPos += 3;
+    }
+  }
+  return (fSignal > fThreshold) ? kTRUE : Next();
+}
+
+void TPCSectorData::PadIterator::Reset()
+{
+  // Return to the beginning of the pad-data. Must call Next() to get to
+  // the first stored signal.
+
+  fPos    = fBeg;
+  fTime   = -1;
+  fSignal = -1;
+  fNChunk = 0;
+}
+
+void TPCSectorData::PadIterator::Reset(const PadData& pd)
+{
+  // Reinitialize to new pad-data. Must call Next() to get to the
+  // first stored signal.
+
+  fBeg = pd.Data();
+  fEnd = pd.Data() + pd.Length();
+  fPos = pd.Data();
+  Reset();
+}
+
+void TPCSectorData::PadIterator::Test()
+{
+  while(Next())
+    printf("  %3d %d\n", fTime, fSignal);
+}
+
+/**************************************************************************/
+// TPCSectorData::RowIterator
+/**************************************************************************/
+
+Bool_t TPCSectorData::RowIterator::NextPad()
+{
+  ++fPad;
+  if(fPad >= fNPads) return kFALSE;
+  Reset(fPadArray[fPad]);
+  return kTRUE;
+}
+
+void TPCSectorData::RowIterator::ResetRow()
+{
+  // Return to the beginning of the row. Must call NextPad() to get to
+  // the zeroth pad.
+
+  fPad = -1;
+}
+
+void TPCSectorData::RowIterator::ResetRow(const PadData* first, Short_t npads)
+{
+  // Reinitialize to another pad-data array. Must call NextPad() to
+  // get to the zeroth pad.
+
+  fPadArray =  first;
+  fNPads    =  npads;
+  fPad      = -1;
+}
+
+void TPCSectorData::RowIterator::Test()
+{
+  while(NextPad()) {
+    printf("Pad %d\n", fPad);
+    PadIterator::Test();
+  }
+}
+
+/**************************************************************************/
+// TPCSectorData::SegmentInfo
+/**************************************************************************/
+
+ClassImp(TPCSectorData::SegmentInfo);
+
+TPCSectorData::SegmentInfo::SegmentInfo()
+{
+  memset(this, sizeof(SegmentInfo), 0);
+}
diff --git a/EVE/Alieve/TPCSectorData.h b/EVE/Alieve/TPCSectorData.h
new file mode 100644 (file)
index 0000000..f162bbd
--- /dev/null
@@ -0,0 +1,195 @@
+// $Header$
+
+#ifndef ALIEVE_TPCSectorData_H
+#define ALIEVE_TPCSectorData_H
+
+#include <Reve/Reve.h>
+
+#include <TObject.h>
+
+#include <vector>
+
+class AliTPCParam;
+
+namespace Alieve {
+
+class TPCSectorData : public TObject
+{
+public:
+
+  class PadData
+  {
+  protected:
+    Short_t* fData;
+    Short_t  fLength;
+
+  public:
+    PadData(Short_t* d=0, Short_t l=0) : fData(d), fLength(l) {}
+
+    Short_t* Data()   const { return fData; }
+    Short_t  Length() const { return fLength; }
+
+    void SetDataLength(Short_t* d, Short_t l) { fData = d; fLength = l; }
+
+    void Print(Option_t* opt="");
+  };
+
+  class PadIterator
+  {
+  protected:
+    Short_t *fBeg, *fEnd, *fPos;
+    Short_t  fTime, fSignal;
+    Short_t  fThreshold;
+    Short_t  fNChunk;
+
+  public:
+    PadIterator(const PadData& pd, Short_t thr=0) :
+      fBeg(pd.Data()), fEnd(pd.Data() + pd.Length()), fPos(pd.Data()),
+      fTime(-1), fSignal(-1), fThreshold(thr), fNChunk(0)
+    {}
+
+    Bool_t Next();
+    void   Reset();
+    void   Reset(const PadData& pd);
+
+    Short_t Time()   const { return fTime; }
+    Short_t Signal() const { return fSignal; }
+
+    Short_t Threshold()    const { return fThreshold; }
+    void SetThreshold(Short_t t) { fThreshold = t; }
+
+    void Test();
+  };
+
+  class RowIterator : public PadIterator
+  {
+  protected:
+    const PadData* fPadArray;
+    Short_t fNPads;
+    Short_t fPad;
+
+  public:
+    RowIterator(const PadData* first, Short_t npads, Short_t thr=0) :
+      PadIterator(*first, thr),
+      fPadArray(first), fNPads(npads),
+      fPad(-1)
+    {}
+
+    Bool_t NextPad();
+    void   ResetRow();
+    void   ResetRow(const PadData* first, Short_t npads);
+    
+    Short_t Pad() const { return fPad; }
+
+    void Test();
+  };
+
+  class SegmentInfo : public TObject
+  {
+    friend class TPCSectorData;
+
+  private:
+    Float_t   fPadWidth;
+    Float_t   fPadHeight;
+    Float_t   fRLow;      // Radius at the bottom of first row
+    Int_t     fNRows;     // Number of rows in this segment
+    Int_t     fFirstRow;  // First row index within sector
+    Int_t     fLastRow;   // Last row index within sector
+    Int_t     fNMaxPads;  // Maximum number of pads in a row
+    Int_t     fNYSteps;   // Number of steps in pad-count
+    Float_t   fYStep[64]; // Y coords where pad-count changes
+
+  public:
+    SegmentInfo();
+
+    Float_t GetPadWidth()  const { return fPadWidth; }
+    Float_t GetPadHeight() const { return fPadHeight; }
+    Float_t GetRLow()      const { return fRLow; }
+    Int_t   GetNRows()     const { return fNRows; }
+    Int_t   GetFirstRow()  const { return fFirstRow; }
+    Int_t   GetLastRow()   const { return fLastRow; }
+    Int_t   GetNMaxPads()  const { return fNMaxPads; }
+    Int_t   GetNYSteps()   const { return fNYSteps; }
+    Float_t GetYStep(Int_t step) const { return fYStep[step]; }
+
+    ClassDef(SegmentInfo, 0);
+  };
+
+private:
+  static AliTPCParam *fgParam;
+  static Int_t        fgNAllRows;
+  static Int_t        fgNAllPads;
+  static Int_t       *fgRowBegs;
+
+  static SegmentInfo  fgInnSeg;
+  static SegmentInfo  fgOut1Seg;
+  static SegmentInfo  fgOut2Seg;
+
+  static SegmentInfo* fgSegInfoPtrs[3];
+
+protected:
+  Int_t                 fSectorID;
+  Int_t                 fNPadsFilled;
+  std::vector<PadData>  fPads;
+
+  // Blocks of pad-data.
+  const Int_t           fBlockSize;
+  Int_t                 fBlockPos;
+  std::vector<Short_t*> fBlocks;
+
+  void NewBlock();
+
+  // Intermediate buffer/vars for pad-data.
+  Short_t fPadBuffer[2048];
+  Int_t   fCurrentRow, fCurrentPad, fCurrentPos, fCurrentStep;
+
+  Int_t PadIndex(Int_t row, Int_t pad) { return fgRowBegs[row] + pad; }
+
+public:
+  TPCSectorData(Int_t sector, Int_t bsize=65536);
+  virtual ~TPCSectorData();
+
+  virtual void Print(Option_t* opt="") const;
+
+  void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE);
+  void RegisterData(Short_t time, Short_t signal);
+  void EndPad();
+
+  const PadData& GetPadData(Int_t padAddr);
+  const PadData& GetPadData(Int_t row, Int_t pad);
+
+  PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0);
+  PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0);
+
+  RowIterator MakeRowIterator(Int_t row, Short_t thr=0);
+
+  // --- Static functions
+
+  static const AliTPCParam& GetParam() { return *fgParam; }
+  static Int_t GetNAllRows() { return fgNAllRows; }
+  static Int_t GetNAllPads() { return fgNAllPads; }
+
+  static Int_t GetNPadsInRow(Int_t row);
+
+  static const SegmentInfo& GetInnSeg()  { return fgInnSeg;  }
+  static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; }
+  static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; }
+
+  static const SegmentInfo& GetSeg(Int_t seg);
+  
+  static void InitStatics();
+
+  ClassDef(TPCSectorData, 0);
+}; // endclass TPCSectorData
+
+
+inline void TPCSectorData::RegisterData(Short_t time, Short_t signal)
+{
+  fPadBuffer[fCurrentPos]   = time;
+  fPadBuffer[fCurrentPos+1] = signal;
+  fCurrentPos += fCurrentStep;
+}
+
+}
+
+#endif
diff --git a/EVE/Alieve/TPCSegment.h b/EVE/Alieve/TPCSegment.h
deleted file mode 100644 (file)
index 8515263..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef ALIEVE_TPCSegment_H
-#define ALIEVE_TPCSegment_H
-
-#include <Reve/RenderElement.h>
-
-#include <Alieve/TPCDigitsInfo.h>
-
-#include <TNamed.h> 
-#include <TBuffer3D.h>
-#include <TBuffer3DTypes.h>
-#include <TGeometry.h>
-#include <TVirtualPad.h>
-#include <TVirtualViewer3D.h>
-#include <TAtt3D.h>
-#include <TAttBBox.h>
-
-
-namespace Alieve {
-
-  class TPCSegmentEditor;
-  class TPCSegmentGL;
-
-  class TPCSegment : public TNamed, public TAtt3D, public TAttBBox, public Reve::RenderElement
-  {
-    friend class TPCSegmentGL;
-    friend class TPCSegmentEditor;
-  private:
-    void Init();
-
-  protected:
-    TPCDigitsInfo*      fInfo; 
-
-    Bool_t              fRnrFrame;
-    Bool_t              fUseTexture;
-    Color_t             fFrameCol;
-
-    // These change data representation:
-    Int_t               fID; 
-    Bool_t             fShowMax;
-    Int_t               fMinTime;     
-    Int_t               fMaxTime;
-    Short_t             fTreshold;
-    Int_t               fMaxVal;
-
-    Double_t            fMatrix[16];
-    Bool_t              fTrans;
-    UInt_t              fRTS;       //! Rendering TimeStamp
-
-  public:
-    TPCSegment(const Text_t* n="TPCSegment", const Text_t* t=0, Color_t col=2) : 
-      TNamed(n,t), Reve::RenderElement(fFrameCol), fFrameCol(col), fRTS(1)
-    { Init(); }
-
-
-    virtual ~TPCSegment();
-
-    void SetInfo(TPCDigitsInfo* diginfo);
-    virtual void SetSegmentID(Int_t id);
-
-    void SetShowMax(Bool_t sm)  { fShowMax  = sm; ++fRTS; }
-    void SetMinTime(Int_t mt)   { fMinTime  = mt; ++fRTS; }
-    void SetMaxTime(Int_t mt)   { fMaxTime  = mt; ++fRTS; }
-    void SetTreshold(Short_t t) { fTreshold =  t; ++fRTS; }
-    void SetMaxVal(Int_t mv)    { fMaxVal   = mv; ++fRTS; }
-
-    virtual void ComputeBBox();
-
-    virtual void Paint(Option_t* option = "");
-
-    virtual void SetTrans(Bool_t t);
-
-    virtual Bool_t CanEditMainColor()  { return true; }
-    ClassDef(TPCSegment, 1);
-  }; // endclass TPCSegment
-
-}
-
-#endif
diff --git a/EVE/Alieve/TPCSegmentEditor.h b/EVE/Alieve/TPCSegmentEditor.h
deleted file mode 100644 (file)
index e684ea0..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Header$
-
-#ifndef ALIEVE_TPCSegmentEditor_H
-#define ALIEVE_TPCSegmentEditor_H
-
-#include <TGedFrame.h>
-
-class TGCheckButton;
-class TGNumberEntry;
-class TGColorSelect;
-class TGDoubleHSlider;
-class TGHSlider;
-
-namespace Alieve {
-
-  class TPCSegment;
-
-  class TPCSegmentEditor : public TGedFrame
-  {
-  protected:
-    TPCSegment* fM; // fModel dynamic-casted to TPCSegmentEditor
-
-    TGCheckButton*   fUseTexture;
-
-    TGNumberEntry*   fSegmentID;
-
-    TGHSlider*       fTreshold;
-    TGHSlider*       fMaxVal;
-
-    TGCheckButton*   fShowMax;
-
-    TGDoubleHSlider* fTime;
-
-  public:
-    TPCSegmentEditor(const TGWindow* p, Int_t id, Int_t width = 170, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground());
-    ~TPCSegmentEditor();
-
-    virtual void SetModel(TVirtualPad* pad, TObject* obj, Int_t event);
-    virtual Bool_t CanEditMainColor()  { return true; }
-
-    // void DoXYZZ();
-    void DoUseTexture();
-
-    void DoSegmentID();
-
-    void DoTreshold();
-    void DoMaxVal();
-    void DoShowMax();
-    void DoTime();
-    ClassDef(TPCSegmentEditor, 1); // Editor for TPCSegment
-  }; // endclass TPCSegmentEditor
-
-}
-
-#endif
diff --git a/EVE/Alieve/TPCSegmentGL.cxx b/EVE/Alieve/TPCSegmentGL.cxx
deleted file mode 100644 (file)
index b6e42d0..0000000
+++ /dev/null
@@ -1,348 +0,0 @@
-// $Header$
-
-#include "TPCSegmentGL.h"
-
-#include <TStyle.h>
-#include <TColor.h>
-#include <TStopwatch.h>
-
-using namespace Reve;
-using namespace Alieve;
-using namespace std;
-
-/**************************************************************************/
-
-TPCSegmentGL::TPCSegmentGL() : TGLObject()
-{
-  fImage   = 0;
-  fTexture = 0;
-  fRTS     = 0;
-}
-
-TPCSegmentGL::~TPCSegmentGL()
-{
-  if(fImage) delete fImage;
-  if(fTexture) glDeleteTextures(1, &fTexture);
-}
-
-/**************************************************************************/
-
-Bool_t TPCSegmentGL::SetModel(TObject* obj)
-{
-  if( set_model(obj, "Alieve::TPCSegment")){
-    fSegment = (TPCSegment*) fExternalObj;
-    return true;
-  }
-  return false;
-}
-
-void TPCSegmentGL::SetBBox()
-{
-  set_axis_aligned_bbox(((TPCSegment*)fExternalObj)->AssertBBox());
-}
-
-/**************************************************************************/
-
-void TPCSegmentGL::DirectDraw(const TGLDrawFlags & ) const
-{
-  // printf("TPCSegmentGL::DirectDraw \n");
-
-  if(fSegment->fInfo == 0 ) return;
-  TPCDigitsInfo* info = fSegment->fInfo;
-
-  if(fRTS < fSegment->fRTS) {
-    CreateTexture(info);
-    fRTS = fSegment->fRTS;
-  }
-
-  glPushAttrib(GL_CURRENT_BIT      | GL_DEPTH_BUFFER_BIT |
-              GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT       | GL_POLYGON_BIT);
-
-  glDisable(GL_LIGHTING);
-  glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
-  glEnable(GL_COLOR_MATERIAL);
-  glDisable(GL_CULL_FACE);
-
-
-  // rnr digits
-  if(fSegment->fUseTexture) {
-    //texture
-    glEnable(GL_BLEND);
-    glDepthMask(GL_FALSE);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glShadeModel(GL_FLAT);
-
-    glBindTexture  (GL_TEXTURE_2D, fTexture);
-
-    glPolygonOffset(2,2);
-    glEnable(GL_POLYGON_OFFSET_FILL);
-
-    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-    glBindTexture(GL_TEXTURE_2D, fTexture);
-    glEnable(GL_TEXTURE_2D);
-
-    DisplayTexture(info->fInnSeg.fPadWidth, info->fInnSeg.fPadLength, info->fInnSeg.fRlow,
-                   info->fInnSeg.fNMaxPads, info->fInnSeg.fNRows, 0,0);
-    DisplayTexture(info->fOut1Seg.fPadWidth, info->fOut1Seg.fPadLength, info->fOut1Seg.fRlow,
-                   info->fOut1Seg.fNMaxPads,info->fOut1Seg.fNRows,info->fInnSeg.fNMaxPads,0);
-    DisplayTexture(info->fOut2Seg.fPadWidth, info->fOut2Seg.fPadLength, info->fOut2Seg.fRlow,
-                   info->fOut2Seg.fNMaxPads, info->fOut2Seg.fNRows,0,info->fOut1Seg.fNRows);
-
-    glDisable(GL_TEXTURE_2D);
-  } else {
-    DisplayQuads(info->fInnSeg.fPadWidth, info->fInnSeg.fPadLength, info->fInnSeg.fRlow,
-                 info->fInnSeg.fNMaxPads, info->fInnSeg.fNRows, 0,0);
-    DisplayQuads(info->fOut1Seg.fPadWidth, info->fOut1Seg.fPadLength, info->fOut1Seg.fRlow,
-                 info->fOut1Seg.fNMaxPads,info->fOut1Seg.fNRows,info->fInnSeg.fNMaxPads,0);
-    DisplayQuads(info->fOut2Seg.fPadWidth, info->fOut2Seg.fPadLength, info->fOut2Seg.fRlow,
-                 info->fOut2Seg.fNMaxPads, info->fOut2Seg.fNRows,0,info->fOut1Seg.fNRows);
-  }
-
-  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-  DisplayFrame(info);
-
-  glPopAttrib();
-}
-
-/**************************************************************************/
-
-void TPCSegmentGL::LoadPadrow(Int_t row, Int_t col_off) const
-{
-  AliSimDigits *digit =  &fSegment->fInfo->fSimDigits;
-
-  Int_t    pad_var = 0;
-  Int_t    time, pad, val;   
-  UChar_t* img_pos;
-
-  Int_t  min_time = fSegment->fMinTime;
-  Int_t max_time = fSegment->fMaxTime;
-  Bool_t half_border_time = ((fSegment->fMaxTime - fSegment->fMinTime) % 2 == 0);
-
-  Bool_t done_p = false;
-  Bool_t save_p = false;
-
-  digit->First();
-  do {
-
-    time = digit->CurrentRow();
-    pad  = digit->CurrentColumn();
-    val  = digit->CurrentDigit();
-
-    Bool_t use_digit = true;
-    if(use_digit) {
-      if(fSegment->fShowMax) {
-       if(val > pad_var) {
-         pad_var = val;
-       }
-      } else {
-       // Integrate int max_val.
-       if(time >= min_time && time <= max_time) {
-         if(half_border_time && (time == min_time || time == max_time))
-           pad_var += val/2;
-         else
-           pad_var += val;
-       }
-      }
-    }
-
-    if(digit->Next()) {
-      if(pad != digit->CurrentColumn())
-       save_p = true;
-    } else {
-      done_p = true;
-      save_p = true;
-    }
-
-    if(save_p) {
-      pad_var = TMath::Min(pad_var, fSegment->fMaxVal);
-      if(pad_var > fSegment->fTreshold) {
-       img_pos = GetRowCol(row, pad + col_off);
-       SetCol(pad_var, img_pos);
-      }
-      pad_var = 0; 
-    }
-
-  } while (!done_p);
-}
-/**************************************************************************/
-
-void TPCSegmentGL::SetCol(Float_t z, UChar_t* pixel) const
-{
-  Int_t n_col = gStyle->GetNumberOfColors();
-
-  Int_t ci = gStyle->GetColorPalette
-    (TMath::Min(n_col - 1,
-               Int_t((n_col*(z - fSegment->fTreshold))/(fSegment->fMaxVal - fSegment->fTreshold))));
-
-  TColor* c = gROOT->GetColor(ci);
-
-  if(c) {
-    //    UChar_t *x = (UChar_t*) &c;
-    pixel[0] = (UChar_t)(255*c->GetRed());
-    pixel[1] = (UChar_t)(255*c->GetGreen());
-    pixel[2] = (UChar_t)(255*c->GetBlue());
-    pixel[3] = 255;
-  }
-}
-
-/**************************************************************************/
-
-void TPCSegmentGL::CreateTexture(TPCDigitsInfo* info) const
-{
-  AliSimDigits *digit = &info->fSimDigits;
-  AliTPCParam  *par   = info->fParameter;
-
-  TTree* t = info->fTree;
-  Int_t s, row, ent, off;
-
-  TStopwatch* sw = new  TStopwatch();
-  sw->Start();
-
-  // init fImage table
-  if (fImage == 0 ){
-    fImage = new UChar_t[ImageWidth*ImageHeight*4];
-    glGenTextures(1, &fTexture);
-  }
-  memset(fImage, 0, ImageWidth*ImageHeight*4);
-
-  ent = info->fSegEnt[fSegment->fID];
-  if(ent != -1) {
-    row=0;
-    // info->fInnSeg.Dump();
-    while(ent < t->GetEntriesFast()) {
-      t->GetEntry(ent);
-      par->AdjustSectorRow(digit->GetID(),s,row);
-      // printf("AdjustSectorRow DigitID %d sector %d row %d \n",digit->GetID(),s,row );
-      if(s != fSegment->fID) break;
-      off =  (info->fInnSeg.fNMaxPads - par->GetNPadsLow(row))/2;
-      LoadPadrow(row, off);
-      ent++;
-    }
-  }
-  ent = info->fSegEnt[fSegment->fID + 36];
-  if(ent != -1) {
-    row=0;
-    // info->fOut1Seg.Dump();
-    while(ent < t->GetEntriesFast()) {
-      t->GetEntry(ent);
-      par->AdjustSectorRow(digit->GetID(),s,row);
-      // printf("AdjustSectorRow DigitID %d sector %d row %d \n",digit->GetID(),s,row );
-      if(s != (fSegment->fID+36)) break;
-
-      if(row < par->GetNRowUp1()) {
-       off =  (info->fOut1Seg.fNMaxPads - par->GetNPadsUp(row))/2;
-       LoadPadrow(row, off + info->fInnSeg.fNMaxPads);
-      } else {
-       off =  (info->fOut2Seg.fNMaxPads - par->GetNPadsUp(row))/2;
-       LoadPadrow(row, off); // info->fInnSeg.fNRows - info->fOut1Seg.fNRows);
-      }
-      ent++;
-    }
-  }
-  sw->Stop();
-  // printf("TPCSegment::CreateTexture timer %f\n", sw->RealTime());
-  // sw->Dump();
-
-  glBindTexture  (GL_TEXTURE_2D, fTexture);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-  // glTexEnvf      (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,   GL_MODULATE); // Lightning is off anyway.
-  glTexImage2D   (GL_TEXTURE_2D, 0, GL_RGBA, ImageWidth, ImageHeight,
-                 0, GL_RGBA, GL_UNSIGNED_BYTE, fImage);
-
-}
-
-void TPCSegmentGL::DisplayTexture(Float_t pw, Float_t pl, Float_t vR,
-                                 Int_t fNMaxPads, Int_t fNRows, 
-                                 Int_t startCol, Int_t startRow) const
-{
-  Float_t w  = fNMaxPads*pw/2;
-  Float_t v1 = 1.0*startRow/ImageHeight;
-  Float_t v2 = v1 + 1.0*fNRows/ImageHeight;
-  Float_t u1 = 1.0 *startCol/ImageWidth;
-  Float_t u2 = u1 + 1.0 *fNMaxPads/ImageWidth;
-  // printf("tex coord u1,v1: (%f, %f), v2,u2: (%f,%f) \n", v1, u1, v2, u2);
-  // printf("vertex coord >>> nPads %d pw %f, w: %f, y1: %f, y2: %f \n",fNMaxPads,pw, w, vR, vR+fNRows*pl);
-  // glColor4f(1.,1.,1.,fSegment->mAlpha); 
-  // glColor4f(1.,1.,1.,1); 
-  glBegin (GL_QUADS);
-  
-  glTexCoord2f(u1, v1);  glVertex3f (-w, vR,           0.0);
-  glTexCoord2f(u1, v2);  glVertex3f (-w, vR+fNRows*pl, 0.0);
-  glTexCoord2f(u2, v2);  glVertex3f ( w, vR+fNRows*pl, 0.0);
-  glTexCoord2f(u2, v1);  glVertex3f ( w, vR,           0.0);
-
-  glEnd();
-}
-
-/**************************************************************************/
-
-void TPCSegmentGL::DisplayQuads(Float_t pw, Float_t pl, Float_t vR,
-                               Int_t fNMaxPads, Int_t fNRows, 
-                               Int_t startCol, Int_t startRow) const
-{
-  UChar_t *pix;
-  Float_t y_d, y_u;
-  Float_t x_off, x;
-
-  glBegin(GL_QUADS);
-  for(Int_t row = 0; row<fNRows; row++){
-    y_d = vR + row*pl;
-    y_u = y_d + pl;
-    x_off = -fNMaxPads*pw/2;
-    for(Int_t pad = 0; pad<fNMaxPads; pad++){
-      pix = GetRowCol(row + startRow, pad + startCol);
-      x = x_off + pad*pw;
-      if(pix[3] != 0){
-       glColor4ubv(pix);
-       glVertex3f(x+pw, y_d, 0);
-       glVertex3f(x,    y_d, 0);
-       glVertex3f(x,    y_u, 0);
-       glVertex3f(x+pw, y_u, 0);
-      }
-    }
-  }
-  glEnd();
-}
-
-/**************************************************************************/
-
-void TPCSegmentGL::DisplayFrame(TPCDigitsInfo* info) const
-{
-  TPCSeg* seg;
-
-  TColor* c = gROOT->GetColor(fSegment->fFrameCol);
-  if(c == 0) return; 
-
-  //  x[0] = (UChar_t)(255*c->GetRed());  x[1] = (UChar_t)(255*c->GetGreen());
-  // x[2] = (UChar_t)(255*c->GetBlue()); x[3] = 255;
-
-  glColor3ub((UChar_t)(255*c->GetRed()), 
-            (UChar_t)(255*c->GetGreen()),
-            (UChar_t)(255*c->GetBlue()));
-
-  seg = &info->fInnSeg;
-  glBegin(GL_LINE_LOOP);
-  LoopStepsUp(seg);
-  LoopStepsDown(seg);
-  glEnd();
-
-  // outer1 segment
-  seg = &info->fOut1Seg;
-  glBegin(GL_LINE_LOOP);
-  LoopStepsUp(seg);
-  LoopStepsDown(seg);
-  glEnd();
-
-  // outer2 segment
-  seg = &info->fOut2Seg;
-  glBegin(GL_LINE_STRIP);
-  LoopStepsUp(seg);
-  LoopStepsDown(seg);
-  glEnd();
-}
diff --git a/EVE/Alieve/TPCSegmentGL.h b/EVE/Alieve/TPCSegmentGL.h
deleted file mode 100644 (file)
index 76b9dd9..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-// $Header$
-
-#ifndef ALIEVE_TPCSegmentGL_H
-#define ALIEVE_TPCSegmentGL_H
-
-
-#include <TGLObject.h>
-
-#include <Alieve/TPCSegment.h>
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-
-namespace Alieve {
-
-  const int ImageWidth  = 256;
-  const int ImageHeight = 128;
-
-  class TPCSegmentGL : public TGLObject
-  {
-  protected:
-    virtual       void DirectDraw(const TGLDrawFlags & flags) const;
-
-  private:
-    void          LoadPadrow(Int_t row, Int_t off) const;
-    void          DisplayTexture(Float_t pw, Float_t pl, Float_t vR, Int_t nMaxPads, 
-                                 Int_t nRows, Int_t startRow,Int_t startCol) const;
-    void          DisplayQuads(Float_t pw, Float_t pl, Float_t vR, Int_t nMaxPads, 
-                               Int_t nRows, Int_t startRow,Int_t startCol) const;
-    void          DisplayFrame(TPCDigitsInfo* info) const;
-
-    GLubyte* GetRow(Int_t row) const;
-    GLubyte* GetRowCol(Int_t row, Int_t col) const;
-
-    // protected:
-    TPCSegment*                         fSegment;
-    mutable UChar_t*             fImage;
-    mutable UInt_t               fTexture;
-    mutable UInt_t               fRTS;
-  public:
-    TPCSegmentGL();
-    virtual       ~TPCSegmentGL();
-    virtual        Bool_t SetModel(TObject* obj); 
-    virtual void   SetBBox();
-
-    void           SetCol(Float_t z, UChar_t* pixel) const;
-    void           CreateTexture(TPCDigitsInfo* info) const;
-
-  }; // endclass TPCSegment_GL_Rnr
-  
-
-  inline  UChar_t* TPCSegmentGL::GetRowCol(Int_t row, Int_t col) const
-  {
-    if ( row > ImageHeight) printf("ERROR row %d ImageHeight %d\n", row, col);
-    return fImage + (ImageWidth*row +col)*4*sizeof(UChar_t); //*sizeof();
-  }
-
-  inline void LoopStepsUp(Alieve::TPCSeg* seg) 
-  {
-    Float_t x = -(seg->fNMaxPads*1.0/2 - seg->fNsteps)*seg->fPadWidth;
-    Float_t y  = seg->fRlow;
-    glVertex3f(x,y,0.);
-    for(int s = 0; s <seg->fNsteps ;s++){
-      y = seg->fStepY[s];
-      glVertex3f(x,y,0.);
-      x -= seg->fPadWidth;
-      glVertex3f(x,y,0.);
-    }
-    y =  seg->fRlow + seg->fNRows*seg->fPadLength;
-    glVertex3f(-seg->fNMaxPads*seg->fPadWidth/2,y,0.);
-  }
-
-  inline void LoopStepsDown(TPCSeg* seg) 
-  {
-    Float_t x = seg->fNMaxPads*seg->fPadWidth/2;
-    Float_t y = seg->fRlow + seg->fNRows*seg->fPadLength;
-    glVertex3f(x,y,0.);
-    for (int s = (seg->fNsteps -1); s >= 0 ;s--){
-      y =  seg->fStepY[s];
-      glVertex3f(x,y,0.);
-      x -= seg->fPadWidth;
-      glVertex3f(x,y,0.);
-    }
-    y = seg->fRlow;
-    glVertex3f((seg->fNMaxPads*1.0/2 - seg->fNsteps)*seg->fPadWidth,y, 0.);
-  }
-}
-
-#endif
diff --git a/EVE/ChangeLog b/EVE/ChangeLog
new file mode 100644 (file)
index 0000000..726795a
--- /dev/null
@@ -0,0 +1,39 @@
+2006-05-18  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       Merged EVE-dev to HEAD.
+       Tagged the EVE-dev branch with EVE-head-merge.
+
+2006-05-18  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * macros/alieve_loadlibs.C:
+       Commented out loading of libg2c as it breaks things at other
+       systems. One should uncomment this at a gcc-4 system.
+
+2006-05-17  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * alice-macros/tpc_digits.C:
+       Use new TPCData classes.
+
+       * libAlieve.pkg:
+       Added RAW to EINCLUDES (need AliTPCRawStreamOld.h in TPCData).
+
+       * macros/alieve_loadlibs.C:
+       Add loading of /usr/lib/libg2c prior to libmicrocern (problem with
+       gcc-4).
+
+       * README:
+       Explain purpose of test-macros/ directory.
+
+       * test-macros/tpc_digi_test.C:
+       * test-macros/tpc_raw_test.C:
+       New files: demonstrate usage of TPCData class.
+
+       * reve-genclass.pl:
+       New file: generate class skeletons from template files.
+
+       * ChangeLog:
+       New file.
index 98fb9a7..0fa8ecc 100644 (file)
@@ -45,6 +45,8 @@ Alieve/ and Reve/ -- sources
 macros/                  -- macros for bootstraping and internal steering
 alice-macros/    -- macros for ALICE visualization
 alica-data/      -- data files used by ALICE macros
+test-macros/      -- macros for tests of specific features; usually one needs
+                     to copy and edit them
 
 bin/, Makefile and make_base.inc are used for stand-alone build of the
 packages.
index 27b7d33..da46406 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "CLASS.h"
 
+using namespace Reve;
 
 //______________________________________________________________________
 // CLASS
@@ -9,8 +10,6 @@
 
 ClassImp(CLASS);
 
-using namespace Reve;
-
 CLASS::CLASS()
 {
 
diff --git a/EVE/Reve/BoxSet.cxx b/EVE/Reve/BoxSet.cxx
new file mode 100644 (file)
index 0000000..e636ff4
--- /dev/null
@@ -0,0 +1,170 @@
+// $Header$
+
+#include "BoxSet.h"
+#include <TRandom.h>
+#include <TBuffer3D.h>
+#include <TBuffer3DTypes.h>
+#include <TGeometry.h>
+#include <TVirtualPad.h>
+#include <TVirtualViewer3D.h>
+
+using namespace Reve;
+
+/**************************************************************************/
+// Box
+/**************************************************************************/
+
+Box::Box(TRandom& rnd, Float_t origin, Float_t size)
+{
+  Reve::ColorFromIdx(Int_t(30*rnd.Rndm()), color);
+  Float_t x0 = 2*origin*(rnd.Rndm() - 0.5);
+  Float_t y0 = 2*origin*(rnd.Rndm() - 0.5);
+  Float_t z0 = 2*origin*(rnd.Rndm() - 0.5);
+  Float_t xo = 2*size*(rnd.Rndm() - 0.5);
+  Float_t yo = 2*size*(rnd.Rndm() - 0.5);
+  Float_t zo = 2*size*(rnd.Rndm() - 0.5);
+  Float_t* p = vertices;
+
+  //bottom
+  p[0] = x0 - xo;  p[1] = y0 + yo, p[2] = z0 - zo;  p += 3;
+  p[0] = x0 + xo;  p[1] = y0 + yo, p[2] = z0 - zo;  p += 3;
+  p[0] = x0 + xo;  p[1] = y0 - yo, p[2] = z0 - zo;  p += 3;
+  p[0] = x0 - xo;  p[1] = y0 - yo, p[2] = z0 - zo;  p += 3;
+  //top
+  p[0] = x0 - xo;  p[1] = y0 + yo, p[2] = z0 + zo;  p += 3;
+  p[0] = x0 + xo;  p[1] = y0 + yo, p[2] = z0 + zo;  p += 3;
+  p[0] = x0 + xo;  p[1] = y0 - yo, p[2] = z0 + zo;  p += 3;
+  p[0] = x0 - xo;  p[1] = y0 - yo, p[2] = z0 + zo;
+}
+
+
+//______________________________________________________________________
+// BoxSet
+//
+
+ClassImp(BoxSet);
+
+void BoxSet::Init()
+{
+  fTrans = false;
+  bbox_init();
+}
+
+/**************************************************************************/
+
+void BoxSet::ComputeBBox()
+{
+  if(fBoxes.empty()) {
+    bbox_zero();
+    return;
+  }
+  bbox_init();
+  for(std::vector<Box>::iterator q=fBoxes.begin(); q!=fBoxes.end(); ++q) {
+    Float_t* p = q->vertices;
+    for(int i=0; i<8; ++i, p+=3)
+      bbox_check_point(p);
+  }
+  printf("%s BBox is x(%f,%f), y(%f,%f), z(%f,%f)\n", GetName(),
+        fBBox[0], fBBox[1], fBBox[2], fBBox[3], fBBox[4], fBBox[5]);
+}
+
+void BoxSet::Paint(Option_t* /*option*/)
+{
+  TBuffer3D buff(TBuffer3DTypes::kGeneric);
+
+  // Section kCore
+  buff.fID           = this;
+  buff.fColor        = 1;
+  buff.fTransparency = 0;
+  buff.fLocalFrame   = fTrans;
+  if (fTrans)
+    memcpy(buff.fLocalMaster, fMatrix, 16*sizeof(Double_t));
+  buff.SetSectionsValid(TBuffer3D::kCore);
+
+  Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
+  if (reqSections == TBuffer3D::kNone) {
+    // printf("BoxSet::Paint viewer was happy with Core buff3d.\n");
+    return;
+  }
+
+  if (reqSections & TBuffer3D::kRawSizes) {
+    Int_t nbPnts = fBoxes.size()*8;
+    Int_t nbSegs = fBoxes.size()*12;
+    Int_t nbPoly = fBoxes.size()*6;
+    if (!buff.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPoly, nbPoly*6)) {
+      return;
+    }
+    buff.SetSectionsValid(TBuffer3D::kRawSizes);
+  }
+
+  if ((reqSections & TBuffer3D::kRaw) && buff.SectionsValid(TBuffer3D::kRawSizes)) {
+    // Points
+    Int_t pidx = 0;
+    for (std::vector<Box>::iterator i=fBoxes.begin(); i!=fBoxes.end(); ++i) {
+      for (Int_t k=0; k<24; ++k) {
+       buff.fPnts[pidx] = (*i).vertices[k];
+       pidx++;
+      }
+    }
+    Int_t c = 2;   // color; !!! wrong
+    Int_t eoff;    // polygon or segment offset in fPols and fSegs array
+    Int_t voff;    // vertex offset
+    Int_t soff;    // offset in counting segments
+    Int_t nspp = 4; // number of segments per polygon
+
+    // Segments & Polygons
+    for (Int_t q = 0; q < (Int_t)fBoxes.size(); ++q) {
+      eoff = q*36;
+      soff = q*12;
+      voff = q*8;
+      //bottom
+      buff.fSegs[ 0 + eoff] = c;  buff.fSegs[ 1 + eoff] = 0 + voff;  buff.fSegs[ 2 + eoff] = 1 + voff;
+      buff.fSegs[ 3 + eoff] = c;  buff.fSegs[ 4 + eoff] = 1 + voff;  buff.fSegs[ 5 + eoff] = 2 + voff;
+      buff.fSegs[ 6 + eoff] = c;  buff.fSegs[ 7 + eoff] = 2 + voff;  buff.fSegs[ 8 + eoff] = 3 + voff;
+      buff.fSegs[ 9 + eoff] = c;  buff.fSegs[10 + eoff] = 3 + voff;  buff.fSegs[11 + eoff] = 0 + voff;
+      // top
+      buff.fSegs[12 + eoff] = c;  buff.fSegs[13 + eoff] = 4 + voff;  buff.fSegs[14 + eoff] = 5 + voff;
+      buff.fSegs[15 + eoff] = c;  buff.fSegs[16 + eoff] = 5 + voff;  buff.fSegs[17 + eoff] = 6 + voff;
+      buff.fSegs[18 + eoff] = c;  buff.fSegs[19 + eoff] = 6 + voff;  buff.fSegs[20 + eoff] = 7 + voff;
+      buff.fSegs[21 + eoff] = c;  buff.fSegs[22 + eoff] = 7 + voff;  buff.fSegs[23 + eoff] = 4 + voff;
+      //sides
+      buff.fSegs[24 + eoff] = c;  buff.fSegs[25 + eoff] = 0 + voff;  buff.fSegs[26 + eoff] = 4 + voff;
+      buff.fSegs[27 + eoff] = c;  buff.fSegs[28 + eoff] = 1 + voff;  buff.fSegs[29 + eoff] = 5 + voff;
+      buff.fSegs[30 + eoff] = c;  buff.fSegs[31 + eoff] = 2 + voff;  buff.fSegs[32 + eoff] = 6 + voff;
+      buff.fSegs[33 + eoff] = c;  buff.fSegs[34 + eoff] = 3 + voff;  buff.fSegs[35 + eoff] = 7 + voff;
+
+      buff.fPols[ 0 + eoff] = c;         buff.fPols[ 1 + eoff] = nspp;
+      buff.fPols[ 2 + eoff] = 0 + soff;  buff.fPols[ 3 + eoff] = 9  + soff;
+      buff.fPols[ 4 + eoff] = 4 + soff;  buff.fPols[ 5 + eoff] = 8  + soff;
+      buff.fPols[ 6 + eoff] = c;         buff.fPols[ 7 + eoff] = nspp;
+      buff.fPols[ 8 + eoff] = 1 + soff;  buff.fPols[ 9 + eoff] = 10 + soff;
+      buff.fPols[10 + eoff] = 5 + soff;  buff.fPols[11 + eoff] = 9  + soff;
+      buff.fPols[12 + eoff] = c;         buff.fPols[13 + eoff] = nspp;
+      buff.fPols[14 + eoff] = 2 + soff;  buff.fPols[15 + eoff] = 11 + soff;
+      buff.fPols[16 + eoff] = 6 + soff;  buff.fPols[17 + eoff] = 10 + soff;
+      buff.fPols[18 + eoff] = c;         buff.fPols[19 + eoff] = nspp;
+      buff.fPols[20 + eoff] = 3 + soff;  buff.fPols[21 + eoff] = 8  + soff;
+      buff.fPols[22 + eoff] = 7 + soff;  buff.fPols[23 + eoff] = 11 + soff;
+      buff.fPols[24 + eoff] = c;         buff.fPols[25 + eoff] = nspp;
+      buff.fPols[26 + eoff] = 0 + soff;  buff.fPols[27 + eoff] = 3  + soff;
+      buff.fPols[28 + eoff] = 2 + soff;  buff.fPols[29 + eoff] = 1  + soff;
+      buff.fPols[30 + eoff] = c;         buff.fPols[31 + eoff] = nspp;
+      buff.fPols[32 + eoff] = 4 + soff;  buff.fPols[33 + eoff] = 5  + soff;
+      buff.fPols[34 + eoff] = 6 + soff;  buff.fPols[35 + eoff] = 7  + soff;
+    }
+    buff.fColor = 2; // colors on polygons are ignored
+    buff.SetSectionsValid(TBuffer3D::kRaw);
+  }
+  gPad->GetViewer3D()->AddObject(buff);
+}
+
+/**************************************************************************/
+
+void BoxSet::Test(Int_t nboxes)
+{
+  TRandom rnd(0);
+  fBoxes.resize(nboxes);
+  for(Int_t i=0; i<nboxes; ++i) {
+    new (&fBoxes[i]) Box(rnd, 10, 2);
+  }
+}
diff --git a/EVE/Reve/BoxSet.h b/EVE/Reve/BoxSet.h
new file mode 100644 (file)
index 0000000..2bae501
--- /dev/null
@@ -0,0 +1,69 @@
+// $Header$
+
+#ifndef REVE_BoxSet_H
+#define REVE_BoxSet_H
+
+#include <Gtypes.h>
+#include <TNamed.h>
+#include <TAtt3D.h>
+#include <TAttBBox.h>
+#include <Reve/Reve.h>
+#include <vector>
+
+class TRandom;
+
+namespace Reve {
+
+struct Box
+{
+  Float_t  vertices[24];
+  UChar_t  color[4];
+
+  Box(Color_t col = 1)
+  { Reve::ColorFromIdx(col, color); }
+  Box(Color_t col, Float_t* p)
+  { Reve::ColorFromIdx(col, color); memcpy(vertices, p, 32*sizeof(Float_t)); }
+
+  Box(TRandom& rnd, Float_t origin, Float_t size);
+
+  virtual ~Box() {}
+
+  ClassDef(Box, 1);
+};
+
+/**************************************************************************/
+
+class BoxSet: public TNamed, public TAtt3D, public TAttBBox
+{
+  friend class BoxSetGL;
+
+private:
+  void Init();
+
+protected:
+  Double_t          fMatrix[16];
+  Bool_t            fTrans;
+
+public:
+  std::vector<Box>  fBoxes;
+
+  BoxSet(const Text_t* n="BoxSet", const Text_t* t="") : TNamed(n, t)
+  { Init(); }
+  virtual ~BoxSet() {}
+
+  void ClearSet() { fBoxes.clear(); }
+
+  Bool_t GetTrans() const   { return fTrans; }
+  void   SetTrans(Bool_t t) { fTrans = t; }
+
+  virtual void ComputeBBox();
+  virtual void Paint(Option_t* option = "");
+
+  void Test(Int_t nboxes);
+
+  ClassDef(BoxSet, 1);
+}; // endclass BoxSet
+
+}
+
+#endif
diff --git a/EVE/Reve/BoxSetGL.cxx b/EVE/Reve/BoxSetGL.cxx
new file mode 100644 (file)
index 0000000..fb9ceca
--- /dev/null
@@ -0,0 +1,88 @@
+// $Header$
+
+#include "BoxSetGL.h"
+#include <Reve/BoxSet.h>
+
+#include <TGLDrawFlags.h>
+#ifdef WIN32
+#include "Windows4root.h"
+#endif
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// BoxSetGL
+//
+
+ClassImp(BoxSetGL);
+
+BoxSetGL::BoxSetGL()
+{
+  // fCached = false; // Disable display list.
+}
+
+BoxSetGL::~BoxSetGL()
+{}
+
+/**************************************************************************/
+
+Bool_t BoxSetGL::SetModel(TObject* obj)
+{
+  return set_model(obj, "Reve::BoxSet");
+}
+
+void BoxSetGL::SetBBox()
+{
+  set_axis_aligned_bbox(((BoxSet*)fExternalObj)->AssertBBox());
+}
+
+/**************************************************************************/
+
+void BoxSetGL::DirectDraw(const TGLDrawFlags& /*flags*/) const
+{
+  BoxSet& mB = * (BoxSet*) fExternalObj;
+  // printf("BoxSetGL::DirectDraw N boxes %d\n", mB.fBoxes.size());
+
+  glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
+  glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
+  glEnable(GL_COLOR_MATERIAL);
+  glDisable(GL_CULL_FACE);
+
+  Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c);
+
+  glBegin(GL_QUADS);
+  for(std::vector<Box>::iterator q=mB.fBoxes.begin(); q!=mB.fBoxes.end(); ++q) {
+    UChar_t* c = (UChar_t*) &q->color;
+    glColor3ub(c[0], c[1], c[2]);
+
+    // bottom: 3210
+    glNormal3f(0, 0, -1);
+    glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices + 6);
+    glVertex3fv(q->vertices + 3);  glVertex3fv(q->vertices);
+    // top:   4567
+    glNormal3f(0, 0, 1);
+    glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 15);
+    glVertex3fv(q->vertices + 18); glVertex3fv(q->vertices + 21);
+    // front: 0154
+    glNormal3f(0, -1, 0);
+    glVertex3fv(q->vertices);      glVertex3fv(q->vertices + 3);
+    glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 12);
+    // back:  7623
+    glNormal3f(0, 1, 0);
+    glVertex3fv(q->vertices + 21); glVertex3fv(q->vertices + 18);
+    glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 9);
+    // left:  4730
+    glNormal3f(-1, 0, 0);
+    glVertex3fv(q->vertices + 12); glVertex3fv(q->vertices + 21);
+    glVertex3fv(q->vertices + 9);  glVertex3fv(q->vertices);
+    // right: 5126
+    glNormal3f(1, 0, 0);
+    glVertex3fv(q->vertices + 15); glVertex3fv(q->vertices + 3);
+    glVertex3fv(q->vertices + 6);  glVertex3fv(q->vertices + 18);
+  }
+  glEnd();
+
+  glPopAttrib();
+}
diff --git a/EVE/Reve/BoxSetGL.h b/EVE/Reve/BoxSetGL.h
new file mode 100644 (file)
index 0000000..6a023b1
--- /dev/null
@@ -0,0 +1,27 @@
+// $Header$
+
+#ifndef REVE_BoxSetGL_H
+#define REVE_BoxSetGL_H
+
+#include <TGLObject.h>
+
+namespace Reve {
+
+class BoxSetGL : public TGLObject
+{
+protected:
+  virtual void DirectDraw(const TGLDrawFlags & flags) const;
+
+public:
+  BoxSetGL();
+  virtual ~BoxSetGL();
+
+  virtual Bool_t SetModel(TObject* obj);
+  virtual void   SetBBox();
+
+  ClassDef(BoxSetGL, 0);
+}; // endclass BoxSetGL
+
+}
+
+#endif
diff --git a/EVE/Reve/ChangeLog b/EVE/Reve/ChangeLog
new file mode 100644 (file)
index 0000000..c64714d
--- /dev/null
@@ -0,0 +1,36 @@
+2006-05-18  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * RGTopFrame.cxx:
+       Added missing initializations. In particular, fCurrentEvent,
+       fCurrentEventLTI and fGeometryLTI were not initialized and this
+       caused segvs for usage without bootstrap with alieve_init.C macro.
+
+2006-05-17  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * LinkDef.h:
+       * Reve.h:
+       New class Reve::ReferenceCount; to be used as secondary base class.
+
+2006-05-15  Matevz Tadel  <matevz.tadel@cern.ch>
+
+       EVE-dev branch
+
+       * Reve.cxx:
+       * Reve.h:
+       New function ColorFromIdx().
+
+       * BoxSet.cxx:
+       * BoxSet.h:
+       * BoxSetGL.cxx:
+       * BoxSetGL.h:
+       New files: a set of boxes with direct GL rendering.
+
+       * LinkDef.h:
+       Pragmas for BoxSet/GL.
+
+       * ChangeLog:
+       New file.
index 4e52893..b10ecbd 100644 (file)
@@ -10,6 +10,7 @@
 //================================
 
 // Reve
+#pragma link C++ function Reve::ColorFromIdx;
 #pragma link C++ function Reve::SetupEnvironment;
 #pragma link C++ function Reve::AssertMacro;
 #pragma link C++ function Reve::Macro;
@@ -19,6 +20,7 @@
 #pragma link C++ class Reve::Exc_t+;
 #pragma link C++ class Reve::PadHolder+;
 #pragma link C++ class Reve::GeoManagerHolder+;
+#pragma link C++ class Reve::ReferenceCount+;
 
 // PODs
 #pragma link C++ class Reve::Vector+;
 #pragma link C++ class Reve::Quad+;
 #pragma link C++ class Reve::QuadSet+;
 
+// BoxSet
+#pragma link C++ class Reve::Box+;
+#pragma link C++ class Reve::BoxSet+;
+
 // GeoNode
 #pragma link C++ class Reve::GeoNodeRnrEl+;
 #pragma link C++ class Reve::GeoTopNodeRnrEl+;
 
 // ReveGLRenderers
 #pragma link C++ class Reve::QuadSetGL+;
+#pragma link C++ class Reve::BoxSetGL+;
index a4ced45..201d3ba 100644 (file)
@@ -69,9 +69,18 @@ ToolBarData_t tb_data[] = {
 
 
 void RGTopFrame::Init(){
-  fSelector = 0;
-  fCC = 0;
-  // fVSDFile = "";
+  fCC          = 0;
+  fHistoCanvas = 0;
+  fSelector    = 0;
+  fBrowser     = 0;
+  fStatusBar   = 0;
+  fVSDFile     = "";
+
+  fEditor = 0;
+
+  fCurrentEvent    = 0;
+  fCurrentEventLTI = 0;
+  fGeometryLTI     = 0;
 
   fRedrawDisabled = false;
   fTimerActive    = false;
index b70100f..ab24249 100644 (file)
@@ -5,6 +5,7 @@
 #include <TError.h>
 #include <TPad.h>
 #include <TGeoManager.h>
+#include <TColor.h>
 
 #include <TROOT.h>
 
@@ -33,6 +34,17 @@ void WarnCaller(const TString& warning)
   std::cout << "WRN: " << warning << std::endl;
 }
 
+void ColorFromIdx(Color_t ci, UChar_t* col)
+{
+  TColor* c = gROOT->GetColor(ci);
+  if(c) { 
+    col[0] = (UChar_t)(255*c->GetRed());  
+    col[1] = (UChar_t)(255*c->GetGreen());
+    col[2] = (UChar_t)(255*c->GetBlue()); 
+    col[3] = 255;
+  }
+}
+
 /**************************************************************************/
 /**************************************************************************/
 
index 0e38bb7..21bea42 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <string>
 #include <TString.h>
+#include <Gtypes.h>
 
 inline bool operator==(const TString& t, const std::string& s)
 { return (s == t.Data()); }
@@ -37,6 +38,8 @@ Exc_t operator+(const Exc_t &s1, const char    *s2);
 
 void WarnCaller(const TString& warning);
 
+void ColorFromIdx(Color_t ci, UChar_t* col);
+
 /**************************************************************************/
 /**************************************************************************/
 
@@ -77,6 +80,25 @@ public:
   ClassDef(GeoManagerHolder, 0);
 };
 
+/**************************************************************************/
+
+class ReferenceCount
+{
+protected:
+  Int_t fRefCount;
+
+public:
+  ReferenceCount() : fRefCount(0) {}
+  virtual ~ReferenceCount() {}
+
+  void IncRefCount() { ++fRefCount; }
+  void DecRefCount() { if(--fRefCount <= 0) OnZeroRefCount(); }
+
+  virtual void OnZeroRefCount() { delete this; }
+
+  ClassDef(ReferenceCount, 0);
+};
+
 }
 
 #endif
index f5ce447..514aab1 100644 (file)
@@ -2,66 +2,51 @@
 
 #include "TGLViewer.h"
 
-void tpc_digits(Int_t mode = 0)
+namespace Alieve {
+class TPCData;
+class Event;
+}
+
+Alieve::TPCData* g_tpc_data = 0;
+Alieve::Event*   g_tpc_last_event = 0;
+
+void tpc_digits(Int_t mode=0)
 {
-  AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
-  rl->LoadDigits("TPC");
-  TTree* dt = rl->GetTreeD("TPC", false);
+  if (g_tpc_data == 0 || g_tpc_last_event != Alieve::gEvent) {
+    AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
+    rl->LoadDigits("TPC");
+    TTree* dt = rl->GetTreeD("TPC", false);
 
-  rl->CdGAFile();
-  AliTPCParam* tpcpar = gDirectory->Get("75x40_100x60_150x60");
+    g_tpc_data = new Alieve::TPCData;
+    g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
 
-  Alieve::TPCDigitsInfo* di = new Alieve::TPCDigitsInfo();
-  di->SetData(tpcpar, dt);
-  // di->Dump();
+    g_tpc_last_event = Alieve::gEvent;
+  }
 
   // Viewport limits.
+  /*
   Float_t left, right, top, bottom;
   right  = di->fOut2Seg.fNMaxPads* di->fOut2Seg.fPadWidth;
   left   = -right;
   bottom = di->fInnSeg.fRlow;
   top    = bottom + di->fOut2Seg.fRlow +
     di->fOut2Seg.fNRows*di->fOut2Seg.fPadLength - di->fInnSeg.fRlow;
+  */
 
   gStyle->SetPalette(1, 0);
   UInt_t col = 36;
 
-  if(mode == 0) {
-    // create an object, so the camera will not jump
+  switch(mode) {
+
+  case 0: { // Display a single sector
    
     gReve->DisableRedraw();
-    Reve::RenderElementList* l = new Reve::RenderElementList("TPC");
-    l->SetTitle("TPC Segment");
-    l->SetMainColor(Color_t(col));
-    TGListTreeItem *ti = gReve->AddRenderElement(l);
   
-    Int_t i = 0;
-    //  for(Int_t i = 0; i<7; i++) {
-    Alieve::TPCSegment* s = new Alieve::TPCSegment();
-    s->SetSegmentID(i);
-    s->SetInfo(di);
+    Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
+    s->SetDataSource(g_tpc_data);
     s->SetMainColor(Color_t(col));
-    l->AddElement(s);
-    gReve->AddRenderElement(ti, s);
-    //  }
-    gReve->DrawRenderElement(l);
-
-
-    /*
-    TPolyMarker3D* framebox = new TPolyMarker3D(8);
-    const Float_t a = 250.0;
-    framebox->SetPoint(0, a, a,a);
-    framebox->SetPoint(1, a, -a,a);
-    framebox->SetPoint(2, -a, -a,a);
-    framebox->SetPoint(3, -a, a,a);
-
-    framebox->SetPoint(4, a, a,-a);
-    framebox->SetPoint(5, a, -a,-a);
-    framebox->SetPoint(6, -a, a,-a);
-    framebox->SetPoint(7, -a, -a,-a);
-
-    framebox->Draw();
-    */
+    gReve->AddRenderElement(s);
+    gReve->DrawRenderElement(s);
 
     gReve->EnableRedraw();
 
@@ -70,7 +55,10 @@ void tpc_digits(Int_t mode = 0)
     //cam->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, 2*left, 2*right, 2*top, bottom); 
     //printf("%f %f %f %f\n", left, right, top, bottom);
 
-  } else {
+    break;
+  }
+
+  case 1: { // Display all sectors
 
     gReve->DisableRedraw();
     {
@@ -80,9 +68,9 @@ void tpc_digits(Int_t mode = 0)
       TGListTreeItem *ti = gReve->AddRenderElement(l);
       
       for(Int_t i = 0; i<18; i++) {
-       Alieve::TPCSegment* s = new Alieve::TPCSegment();
+       Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
        s->SetSegmentID(i);
-       s->SetInfo(di);
+       s->SetDataSource(g_tpc_data);
        s->SetMainColor(Color_t(col));
        s->SetTrans(true);
        l->AddElement(s);
@@ -97,10 +85,10 @@ void tpc_digits(Int_t mode = 0)
 
       TGListTreeItem *ti = gReve->AddRenderElement(l);
       for(Int_t i = 18; i<36; i++) {
-       Alieve::TPCSegment* s = new Alieve::TPCSegment();
+       Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
        s->SetSegmentID(i);
+       s->SetDataSource(g_tpc_data);
        s->SetMainColor(Color_t(col));
-       s->SetInfo(di);
        s->SetTrans(true);
        l->AddElement(s);
        gReve->AddRenderElement(ti, s);
@@ -108,5 +96,26 @@ void tpc_digits(Int_t mode = 0)
       gReve->DrawRenderElement(l);
     }
     gReve->EnableRedraw();
+
+    break;
   }
+
+    /* // Almost ready ...
+  case 2 : { // Display a single sector in 3D
+    Reve::RenderElementList* l = new Reve::RenderElementList("TPC Drift");
+    l->SetTitle("TPC Segment Drift");
+    l->SetMainColor(Color_t(col));
+    TGListTreeItem *ti = gReve->AddRenderElement(l);
+  
+    Alieve::TPCSector3D* = new Alieve::TPCSector3D(di, 0);
+    s->SetMainColor(Color_t(col));
+    l->AddElement(s);
+    gReve->AddRenderElement(ti, s);
+    gReve->DrawRenderElement(l);
+    gReve->EnableRedraw();
+    break;
+  }
+    */
+
+  } // switch
 }
index 37e6472..dee7c98 100644 (file)
@@ -4,4 +4,4 @@ HDRS     := $(SRCS:.cxx=.h)
 
 DHDR     := Alieve/LinkDef.h
 
-EINCLUDE := ITS TPC
+EINCLUDE := ITS TPC RAW
index a818023..8b25b7e 100644 (file)
@@ -12,6 +12,8 @@ void alieve_loadlibs ()
   // Uncomment the following line for macosx
   // Waiting for a better solution
   //  gSystem->Load("libg2c_sh");
+  // And the following works for gcc-4.
+  //  gSystem->Load("/usr/lib/libg2c");
   gSystem->Load("libmicrocern");
   gSystem->Load("libpdf");
   gSystem->Load("libpythia6");
diff --git a/EVE/reve-genclass.pl b/EVE/reve-genclass.pl
new file mode 100755 (executable)
index 0000000..dc4d851
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/perl
+
+my ($BINDIR, $BINNAME) = $0 =~ m!^(.*)/(.*)!;
+if ($#ARGV != 1) {
+  print STDERR <<"fnord";
+usage: $BINNAME <module> <class-base>
+   eg: $BINNAME base QuadSet
+       $BINNAME gl   QuadSet
+       $BINNAME ged  QuadSet
+Should be in module sub-directory (reve/ or alieve/).
+Note that GL and Editor siffixes are not present!
+fnord
+  exit 1;
+}
+
+my $MODULE = $ARGV[0];
+# Flat structure now.
+# die "'$MODULE' not a directory" unless -d $MODULE;
+
+%suff = ( 'gl' => 'GL', 'ged' => 'Editor');
+my $STEM  = $ARGV[1];
+my $CLASS = $STEM . $suff{$MODULE};
+
+# Flat structure now.
+# my $H_NAME = "$MODULE/$CLASS.h";
+# my $C_NAME = "$MODULE/$CLASS.cxx";
+my $H_NAME = "$CLASS.h";
+my $C_NAME = "$CLASS.cxx";
+
+die "File '$H_NAME' already exists" if -e $H_NAME;
+die "File '$C_NAME' already exists" if -e $C_NAME;
+
+sub find_skel {
+  my ($stem, $suff) = @_;
+  my $file1 = "$stem-$MODULE.$suff";
+  return $file1 if -e $file1;
+  my $file2 = "$stem.$suff";
+  return $file2 if -e $file2;
+  die "Skeleton file not found neither as '$file 1' nor '$file2'";
+}
+
+my $SKEL_H_NAME = find_skel(".SKEL", "h");
+my $SKEL_C_NAME = find_skel(".SKEL", "cxx");
+
+print "Using skeleton files '$SKEL_H_NAME' and '$SKEL_C_NAME'\n";
+
+my ($skel_h, $skel_c);
+{
+  my $ex_sla = $/; undef $/;
+  open H, "$SKEL_H_NAME" or die "can't open $SKEL_H_NAME";
+  $skel_h = <H>; close H;
+  open C, "$SKEL_C_NAME" or die "can't open $SKEL_C_NAME";
+  $skel_c = <C>; close C;
+  $/ = $ex_sla;
+}
+
+print "Replacing CLASS -> $CLASS, STEM -> $STEM.\n";
+
+for $f ($skel_h, $skel_c) {
+  $f =~ s/CLASS/$CLASS/g;
+  $f =~ s/STEM/$STEM/g;
+}
+
+print "Writing files '$H_NAME', '$C_NAME'.\n";
+
+open H, ">$H_NAME" or
+  die "can't open $H_NAME";
+print H $skel_h; close H;
+open H, ">$C_NAME" or
+  die "can't open $C_NAME";
+print H $skel_c; close H;
+
+if($DUMPINFO) {
+  print "# Now you should also edit the link-def file.\n";
+  print "# Remember to run 'make depend'.\n";
+}
diff --git a/EVE/test-macros/tpc_digi_test.C b/EVE/test-macros/tpc_digi_test.C
new file mode 100644 (file)
index 0000000..85f0b0b
--- /dev/null
@@ -0,0 +1,68 @@
+class TTree;
+
+namespace Alieve {
+class TPCData;
+}
+
+Alieve::TPCData*  x = 0;
+TTree*            tree = 0;
+
+void tpc_digi_test()
+{
+  gROOT->Macro("alieve_loadlibs.C");
+  gSystem->Load("libAlieve");
+
+  TFile* f = new TFile("coctail_1k/TPC.Digits.root");
+  tree = (TTree*) gDirectory->Get("Event0/TreeD");
+
+  x = new Alieve::TPCData;
+  // x->SetSectorBlockSize(8192);
+  // x->SetLoadThreshold(5);
+  x->CreateAllSectors();
+  x->LoadDigits(tree, kFALSE);
+  gStyle->SetPalette(1, 0);
+
+  Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
+  s->SetDataSource(x);
+  s->SetMainColor(36);
+  gReve->AddRenderElement(s);
+  gReve->DrawRenderElement(s);
+}
+
+
+void tpc_digi_pad_dump(Int_t s, Int_t r, Int_t p)
+{
+  if(r >= Alieve::TPCSectorData::GetInnSeg().fNRows) {
+    r -= Alieve::TPCSectorData::GetInnSeg().fNRows;
+    s += 36;
+  }
+
+  AliSimDigits *digit = 0;
+  tree->GetBranch("Segment")->SetAddress(&digit);
+  
+  Int_t sbr = (Int_t) tree->GetEntries();
+  for (Int_t ent=0; ent<sbr; ent++) {
+    tree->GetEntry(ent);
+    Int_t sector, row;
+    Alieve::TPCSectorData::GetParam().AdjustSectorRow(digit->GetID(), sector, row);
+
+    if(sector != s || row != r)
+      continue;
+
+    printf("Entry = %d, ID = %d, Sec = %d, Row = %d\n",
+          ent, digit->GetID(), sector, row);
+
+    Int_t pad;
+    Short_t time, signal;
+    digit->First();
+    do {
+      pad    = digit->CurrentColumn();
+      time   = digit->CurrentRow();
+      signal = digit->CurrentDigit();
+
+      if(p == pad)
+       printf("%d %d\n", time, signal);
+
+    } while (digit->Next());
+  }
+}
diff --git a/EVE/test-macros/tpc_raw_test.C b/EVE/test-macros/tpc_raw_test.C
new file mode 100644 (file)
index 0000000..8becb31
--- /dev/null
@@ -0,0 +1,64 @@
+class AliRawReaderFile;
+
+namespace Alieve {
+class TPCData;
+}
+
+Alieve::TPCData*  x = 0;
+AliRawReaderFile* reader = 0;
+
+void tpc_raw_test()
+{
+  gROOT->Macro("alieve_loadlibs.C");
+  gSystem->Load("libAlieve");
+
+  reader = new AliRawReaderFile("raw0");
+  reader->Reset();
+  reader->NextEvent();
+  AliTPCRawStream input(reader);
+
+  x = new Alieve::TPCData;
+  //x->SetSectorBlockSize(8192);
+  //x->SetLoadThreshold(5);
+  x->CreateAllSectors();
+  x->LoadRaw(input, kFALSE);
+
+  gStyle->SetPalette(1, 0);
+
+  Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
+  s->SetDataSource(x);
+  s->SetMainColor(36);
+  gReve->AddRenderElement(s);
+  gReve->DrawRenderElement(s);
+
+}
+
+void tpc_raw_pad_dump(Int_t s, Int_t r, Int_t p)
+{
+  reader->Reset();
+  reader->NextEvent();
+
+  if(r >= Alieve::TPCSectorData::GetInnSeg().fNRows) {
+    r -= Alieve::TPCSectorData::GetInnSeg().fNRows;
+    s += 36;
+  }
+
+  AliTPCRawStream input(reader);
+  Int_t sector = input.GetSector();
+  Int_t row    = input.GetRow();
+
+  while (input.Next()) {
+    if (input.IsNewRow()) {
+      sector = input.GetSector();
+      row    = input.GetRow();
+    }
+    if(sector != s || row != r) continue;
+
+    Int_t signal = input.GetSignal();
+    Int_t pad    = input.GetPad();
+    Int_t time   = input.GetTime();
+
+    if(pad == p)
+      printf("%d %d\n", time, signal);
+  }
+}