New files from Alexandru: TRD visualization.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Oct 2006 16:26:42 +0000 (16:26 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 27 Oct 2006 16:26:42 +0000 (16:26 +0000)
EVE/Alieve/TRDData.cxx [new file with mode: 0644]
EVE/Alieve/TRDData.h [new file with mode: 0644]
EVE/Alieve/TRDLoader.cxx [new file with mode: 0644]
EVE/Alieve/TRDLoader.h [new file with mode: 0644]
EVE/Alieve/TRDModule.cxx [new file with mode: 0644]
EVE/Alieve/TRDModule.h [new file with mode: 0644]
EVE/Alieve/TRDModuleImp.cxx [new file with mode: 0644]
EVE/Alieve/TRDModuleImp.h [new file with mode: 0644]

diff --git a/EVE/Alieve/TRDData.cxx b/EVE/Alieve/TRDData.cxx
new file mode 100644 (file)
index 0000000..b614d8f
--- /dev/null
@@ -0,0 +1,160 @@
+#include "TRDData.h"
+#include "TRDModuleImp.h"
+
+#include "AliTRDcalibDB.h"
+#include "AliTRDpadPlane.h"
+#include "AliTRDgeometry.h"
+
+using namespace Reve;
+using namespace Alieve;
+using namespace std;
+
+ClassImp(TRDDigits)
+ClassImp(TRDHits)
+
+///////////////////////////////////////////////////////////
+/////////////   TRDDigits             /////////////////////
+///////////////////////////////////////////////////////////
+
+//________________________________________________________
+TRDDigits::TRDDigits(TRDChamber *p): QuadSet("digits", ""), RenderElement()
+{
+       fChamber = p;
+       
+       kLog = kFALSE;
+       kBox  = kFALSE;
+       fThreshold = 10;
+}
+
+//________________________________________________________
+void   TRDDigits::SetData(AliTRDdataArrayI *digits)
+{
+       
+       fData.Allocate(fChamber->rowMax, fChamber->colMax, fChamber->timeMax);
+       digits->Expand();
+       for (Int_t  row = 0;  row <  fChamber->rowMax;  row++)
+               for (Int_t  col = 0;  col <  fChamber->colMax;  col++)
+                       for (Int_t time = 0; time < fChamber->timeMax; time++) {
+//             if(digits->GetDataUnchecked(row, col, time) > 20) printf("%d %d %d %d\n", row, col, time, digits->GetDataUnchecked(row, col, time));
+               fData.SetDataUnchecked(row, col, time, digits->GetDataUnchecked(row, col, time));
+       }
+}
+
+//________________________________________________________
+void   TRDDigits::ComputeRepresentation()
+{
+// Calculate digits representation according to user settings. The
+// user can set the following parameters:
+// - digits scale (log/lin)
+// - digits threshold
+// - digits apparence (quads/boxes)
+
+       fQuads.clear();
+       fBoxes.fBoxes.clear();
+               
+       Double_t colSize, rowSize, scale;
+       Double_t x, y, z;
+
+       Int_t charge;
+       Float_t t0;
+       Float_t timeBinSize;
+       
+       AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
+  Double_t cloc[4][3], cglo[3];
+       Int_t color, dimension;
+       fData.Expand();
+       for (Int_t  row = 0;  row <  fChamber->rowMax;  row++) {
+               rowSize = .5 * fChamber->fPadPlane->GetRowSize(row);
+               z = fChamber->fPadPlane->GetRowPos(row) - rowSize;
+               
+               for (Int_t  col = 0;  col <  fChamber->colMax;  col++) {
+                       colSize = .5 * fChamber->fPadPlane->GetColSize(col);
+                       y = fChamber->fPadPlane->GetColPos(col) - colSize;
+                       t0 = calibration->GetT0(fChamber->fDet, col, row);
+                       timeBinSize = calibration->GetVdrift(fChamber->fDet, col, row)/fChamber->samplingFrequency;
+                       
+                       for (Int_t time = 0; time < fChamber->timeMax; time++) {
+                               charge = fData.GetDataUnchecked(row, col, time);
+                       if (charge < fThreshold) continue;
+                               
+                               x = fChamber->fX0 - (time+0.5-t0)*timeBinSize;
+                               scale = kLog ? TMath::Log(float(charge))/TMath::Log(1024.) : charge/1024.;
+                               color  = 50+int(scale*50.);
+                               
+                               cloc[0][2] = z - rowSize * scale;
+                               cloc[0][1] = y - colSize * scale;
+                               cloc[0][0] = x;
+                       
+                               cloc[1][2] = z - rowSize * scale;
+                               cloc[1][1] = y + colSize * scale;
+                               cloc[1][0] = x;
+                       
+                               cloc[2][2] = z + rowSize * scale;
+                               cloc[2][1] = y + colSize * scale;
+                               cloc[2][0] = x;
+                       
+                               cloc[3][2] = z + rowSize * scale;
+                               cloc[3][1] = y - colSize * scale;
+                               cloc[3][0] = x;
+       
+                               Float_t* p;
+                               if(kBox){
+                                       fBoxes.fBoxes.push_back(Reve::Box());
+                                       fBoxes.fBoxes.back().color[0] = (UChar_t)color;
+                                       fBoxes.fBoxes.back().color[1] = (UChar_t)color;
+                                       fBoxes.fBoxes.back().color[2] = (UChar_t)color;
+                                       fBoxes.fBoxes.back().color[3] = (UChar_t)color;
+                                       p = fBoxes.fBoxes.back().vertices;
+                                       dimension = 2;
+                               } else {
+                                       fQuads.push_back(Reve::Quad());
+                                       fQuads.back().ColorFromIdx(color);
+                                       p = fQuads.back().vertices;
+                                       dimension = 1;
+                               }
+
+                               for(int id=0; id<dimension; id++)
+                               for (Int_t ic = 0; ic < 4; ic++) {
+                                       cloc[ic][0] -= .5 * id * timeBinSize;
+                                       fChamber->fGeo->RotateBack(fChamber->fDet,cloc[ic],cglo);
+               p[0] = cglo[0]; p[1] = cglo[1]; p[2] = cglo[2];
+                                       p+=3;
+                               }
+                       }  // end time loop
+               }  // end col loop
+       }  // end row loop
+       fData.Compress(1);
+}
+
+//________________________________________________________
+void TRDDigits::Paint(Option_t *option)
+{
+       if(kBox) fBoxes.Paint(option);
+       else QuadSet::Paint(option);
+}
+
+//________________________________________________________
+void TRDDigits::Reset()
+{
+       fQuads.clear();
+       fBoxes.fBoxes.clear();
+       fData.Reset();
+}
+
+///////////////////////////////////////////////////////////
+/////////////   TRDHits               /////////////////////
+///////////////////////////////////////////////////////////
+
+//________________________________________________________
+TRDHits::TRDHits(const Text_t* name, Int_t n_points):PointSet(name, n_points)
+{
+
+}
+
+//________________________________________________________
+void TRDHits::PointSelected(Int_t n)
+{
+       printf("void TRDHits::PointSelected(%d)\n", n);
+//     printf("Detector %d\n", ((TRDChamber*)GetPointId(n))->GetDetector());
+}
+
diff --git a/EVE/Alieve/TRDData.h b/EVE/Alieve/TRDData.h
new file mode 100644 (file)
index 0000000..d7d56d3
--- /dev/null
@@ -0,0 +1,66 @@
+/////////////////////////////////////////////////////////////////////////
+//
+// - AliEVE implementation -
+// Containers for visualisation of TRD data structures 
+//    - TRDHits - visualisation of MC Hits, Clusters (RecPoints)
+//    - TRDDigits - visualisation of TRD digits
+//
+// by A.Bercuci (A.Bercuci@gsi.de)   Fri Oct 27 2006
+///////////////////////////////////////////////////////////////////////
+
+#ifndef ALIEVE_TRDData_H
+#define ALIEVE_TRDData_H
+
+#ifndef REVE_QuadSet_H
+#include <Reve/QuadSet.h>
+#endif
+
+#ifndef REVE_BoxSet_H
+#include <Reve/BoxSet.h>
+#endif
+
+#ifndef REVE_PointSet_H
+#include <Reve/PointSet.h>
+#endif
+
+#include "AliTRDdataArrayI.h"
+
+namespace Alieve {
+       class TRDChamber;
+       class TRDHits : public Reve::PointSet
+       {
+       public:
+               TRDHits(const Text_t* name, Int_t n_points = 0);
+
+               void PointSelected(Int_t n);
+
+       ClassDef(TRDHits,1) // Base class for TRD hits visualisation
+       };
+
+               
+       class TRDDigits : public Reve::QuadSet, public Reve::RenderElement
+       {
+       public:
+               TRDDigits(TRDChamber *p);
+
+               void                    ComputeRepresentation();
+               void                    Paint(Option_t *opt="");
+               void                    Reset();
+               void                    SetShow(Bool_t log=kFALSE, Bool_t box=kFALSE){kLog = log; kBox=box;}
+               void                    SetData(AliTRDdataArrayI *digits);
+               void                    SetThreshold(Int_t t){fThreshold = t;}
+
+       protected:
+               TRDChamber *fChamber;
+       
+       private:
+               Bool_t                                          kLog, kBox;
+               UShort_t                                        fThreshold;
+               Reve::BoxSet                    fBoxes;
+               AliTRDdataArrayI        fData;
+               
+               ClassDef(TRDDigits,1) // Digits visualisation for TRD
+       };
+}
+
+#endif
diff --git a/EVE/Alieve/TRDLoader.cxx b/EVE/Alieve/TRDLoader.cxx
new file mode 100644 (file)
index 0000000..2094912
--- /dev/null
@@ -0,0 +1,489 @@
+#include "TRDLoader.h"
+#include "TRDModuleImp.h"
+
+#include <Reve/RGTopFrame.h>
+#include <Reve/RGValuators.h>
+
+#include <TSystem.h>
+#include <TGLabel.h>
+#include <TGButton.h>
+#include <TGTextEntry.h>
+#include <TGNumberEntry.h>
+#include <TGFileDialog.h>
+#include <TGListTree.h>
+#include <TGToolTip.h>
+
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
+#include "AliCDBManager.h"
+
+#include "AliTRDv1.h"
+#include "AliTRDhit.h"
+#include "AliTRDcluster.h"
+#include "AliTRDmcmTracklet.h"
+#include "AliTRDdigitsManager.h"
+#include "AliTRDgeometry.h"
+
+#include <algorithm>
+
+using namespace Reve;
+using namespace Alieve;
+using namespace std;
+class AliTRDdataArrayI;
+
+ClassImp(Alieve::TRDLoader)
+ClassImp(Alieve::TRDLoaderEditor)
+
+///////////////////////////////////////////////////////////
+/////////////         TRDLoader       /////////////////////
+///////////////////////////////////////////////////////////
+
+
+//________________________________________________________
+TRDLoader::TRDLoader(const Text_t* n, const Text_t* t) : Reve::RenderElementListBase(), TNamed(n,t)
+{
+//     fChambers = 0x0;
+       fRunLoader = 0x0;
+//     fTRDLoader = 0x0;
+       
+       kLoadHits = kFALSE;
+       kLoadDigits = kFALSE;
+       kLoadClusters = kFALSE;
+       kLoadTracks = kFALSE;
+       
+       AliCDBManager *fCDBManager=AliCDBManager::Instance();
+       fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
+       fCDBManager->SetRun(0);
+}
+
+//________________________________________________________
+TRDLoader::~TRDLoader()
+{
+//     if(fChambers) {fChambers->clear(); delete fChambers;}
+}
+
+//________________________________________________________
+template<class T>
+class ID
+{
+public:
+       ID( const int value ) : id(value) {}
+       bool operator()(const T &t) const {
+               return ((dynamic_cast<TRDModule*>(t))->GetID() == id);
+       }
+private:
+       const int id;
+};
+void   TRDLoader::AddChambers(const int sm, const int stk, const int ly)
+{
+       Int_t ism_start = (sm == -1) ?  0 : sm;
+       Int_t ism_stop  = (sm == -1) ? 18 : sm+1;
+       Int_t istk_start= (stk == -1)?  0 : stk;
+       Int_t istk_stop = (stk == -1)?  5 : stk+1;
+       Int_t ily_start = (ly == -1) ?  0 : ly;
+       Int_t ily_stop  = (ly == -1) ?  6 : ly+1;
+
+       lpRE_i ichmb;
+       ichmb = fChildren.begin();
+       while(ichmb != fChildren.end()){
+               (*ichmb)->SetRnrElement(kFALSE);
+               ichmb++;
+       }
+
+       TRDNode *SM=0x0, *STK=0x0;
+       TRDChamber *CHMB = 0x0;
+       int det;
+       for(int ism=ism_start; ism<ism_stop; ism++){
+               ichmb = find_if(fChildren.begin(), fChildren.end(), ID<RenderElement*>(ism));
+               if(ichmb != fChildren.end()){
+                       SM = (TRDNode*)(*ichmb);
+                       SM->SetRnrElement(kTRUE);
+               }else{
+                       gReve->AddRenderElement(this, SM = new TRDNode("SM", ism));
+                       SM->FindListTreeItem(gReve->GetListTree())->SetTipText(Form("Supermodule %2d", ism));
+               }
+               for(int istk=istk_start; istk<istk_stop; istk++){
+                       ichmb = find_if(SM->begin(), SM->end(), ID<RenderElement*>(istk));
+                       if(ichmb != SM->end()){
+                               STK = (TRDNode*)(*ichmb);
+                               STK->SetRnrElement(kTRUE);
+                       }else{
+                               gReve->AddRenderElement(SM, STK = new TRDNode("Stack", istk));
+                               STK->FindListTreeItem(gReve->GetListTree())->SetTipText(Form("SM %2d Stack %1d", ism, istk));
+                       }
+                       for(int ily=ily_start; ily<ily_stop; ily++){
+                               det = AliTRDgeometry::GetDetector(ily, istk, ism);
+                               ichmb = find_if(STK->begin(), STK->end(), ID<RenderElement*>(det));
+                               if(ichmb != STK->end()) (*ichmb)->SetRnrElement(kTRUE);
+                               else{
+                                       gReve->AddRenderElement(STK, CHMB = new TRDChamber(det));
+                                       CHMB->FindListTreeItem(gReve->GetListTree())->SetTipText(Form("SM %2d Stack %1d Layer %1d", ism, istk, ily));
+                               }
+                       }
+               }
+       }
+       gReve->Redraw3D();
+}
+
+//________________________________________________________
+TRDChamber*    TRDLoader::GetChamber(const int d)
+{
+       lpRE_i ism, istack, ichmb;
+       AliTRDgeometry *geo = fTRD->GetGeometry();
+       
+       ism = find_if(fChildren.begin(), fChildren.end(), ID<RenderElement*>(geo->GetSector(d)));
+       if(ism == fChildren.end()) return 0x0;
+       istack = find_if(((TRDNode*)(*ism))->begin(), ((TRDNode*)(*ism))->end(), ID<RenderElement*>(geo->GetChamber(d)));
+       if(istack == ((TRDNode*)(*ism))->end()) return 0x0;
+       ichmb = find_if(((TRDNode*)(*istack))->begin(), ((TRDNode*)(*istack))->end(), ID<RenderElement*>(d));
+       if(ichmb == ((TRDNode*)(*istack))->end()) return 0x0;
+       return dynamic_cast<TRDChamber*>(*ichmb);
+}
+
+//________________________________________________________
+Bool_t TRDLoader::GoToEvent(const int ev)
+{
+       Info("GoToEvent", Form("Event = %d", ev));
+       if(!fRunLoader) return kFALSE;
+       fRunLoader->UnloadAll("TRD");
+       Unload();
+       
+       fRunLoader->GetEvent(ev);
+       TTree *t = 0x0;
+       if(kLoadHits){
+               fRunLoader->LoadHits("TRD", "READ");
+               t = fRunLoader->GetTreeH("TRD", kFALSE);
+               if(!t) return kFALSE;
+               fTRD->SetTreeAddress();
+               if(!LoadHits(t)) return kFALSE;
+       }
+       if(kLoadDigits){
+               fRunLoader->LoadDigits("TRD", "READ");
+               t = fRunLoader->GetTreeD("TRD", kFALSE);
+               if(!t) return kFALSE;
+               fTRD->SetTreeAddress();
+               if(!LoadDigits(t)) return kFALSE;
+       }
+       if(kLoadClusters){
+               fRunLoader->LoadRecPoints("TRD", "READ");
+               t = fRunLoader->GetTreeR("TRD", kFALSE);
+               if(!t) return kFALSE;
+               if(!LoadClusters(t)) return kFALSE;
+       }
+       if(kLoadTracks){
+               fRunLoader->LoadTracks("TRD", "READ");
+               t = fRunLoader->GetTreeT("TRD", kFALSE);
+               if(!t) return kFALSE;
+               if(!LoadTracklets(t)) return kFALSE;
+       }
+       gReve->Redraw3D();
+       return kTRUE;
+}
+
+
+//________________________________________________________
+Bool_t TRDLoader::LoadClusters(TTree *tC)
+{
+       Info("LoadClusters()", Form("Clusters tree 0x%x", tC));
+       if(!fChildren.size()) return kTRUE;
+
+       TObjArray *clusters = new TObjArray();
+       tC->SetBranchAddress("TRDcluster",&clusters);
+
+       TRDChamber *chmb = 0x0; 
+       AliTRDcluster *c=0x0;
+       for(int idet=0; idet<540; idet++){
+               if(!tC->GetEntry(idet)) continue;
+               if(clusters->GetEntriesFast()) c = (AliTRDcluster*)clusters->UncheckedAt(0);
+               if((chmb = GetChamber(c->GetDetector()))) chmb->LoadClusters(clusters);
+       }
+       return kTRUE;
+}
+
+
+//________________________________________________________
+Bool_t TRDLoader::LoadDigits(TTree *tD)
+{
+       Info("LoadDigits()", Form("Digits tree 0x%x", tD));
+       
+       if(!fChildren.size()) return kTRUE;
+       
+       TRDChamber *chmb;
+       AliTRDdataArrayI *digits;
+       AliTRDdigitsManager dm;
+       dm.ReadDigits(tD);
+       for(int idet=0; idet<540; idet++){
+               if(!(chmb=GetChamber(idet))) continue;
+               digits = dm.GetDigits(idet);
+               if(!digits) continue;
+               chmb->LoadDigits(digits);
+       }
+       return kTRUE;
+}
+
+
+//________________________________________________________
+Bool_t TRDLoader::LoadHits(TTree *tH)
+{
+       Info("LoadHits()", Form("Hits tree 0x%x", tH));
+       if(!fChildren.size()) return kTRUE;
+       
+       TRDChamber *chmb = 0x0;
+       AliTRDhit *hit;
+       Int_t d;
+       for(int iTrack=0; iTrack<tH->GetEntries(); iTrack++){
+               gAlice->ResetHits();
+               if(!tH->GetEvent(iTrack)) continue;
+               hit = (AliTRDhit*)fTRD->FirstHit(-1);
+               if(!hit) continue;
+               d = hit->GetDetector();
+               chmb = GetChamber(d);
+               while(hit){
+                       if(d != hit->GetDetector()){
+                               d = hit->GetDetector();
+                               chmb = GetChamber(d);
+                       }
+                       if(chmb) chmb->AddHit(hit);
+                       hit = (AliTRDhit*)fTRD->NextHit();
+               }
+       }
+       return kTRUE;
+}
+
+//________________________________________________________
+Bool_t TRDLoader::LoadTracklets(TTree *tT)
+{
+       Info("LoadTracklets()", Form("Tracks tree 0x%x", tT));
+       if(!fChildren.size()) return kTRUE;
+
+       TObjArray *tracks = new TObjArray();
+       tT->SetBranchAddress("TRDmcmTracklet",&tracks);
+       
+       TRDChamber *chmb = 0x0;
+       AliTRDmcmTracklet *trk=0x0;
+       for(int idet=0; idet<540; idet++){
+               if(!tT->GetEntry(idet)) continue;
+               if(tracks->GetEntriesFast()) trk = (AliTRDmcmTracklet*)tracks->UncheckedAt(0);
+               if((chmb = GetChamber(trk->GetDetector()))) chmb->LoadTracklets(tracks);
+       }
+       
+       return kTRUE;
+}
+       
+//________________________________________________________
+Bool_t TRDLoader::Open(const char *filename)
+{
+       fRunLoader = AliRunLoader::GetRunLoader();
+       if(!fRunLoader) fRunLoader = AliRunLoader::Open(filename,
+                               AliConfig::GetDefaultEventFolderName(),"read");
+       if(!fRunLoader){
+               Error("Open()", "Couldn't find run loader");
+               return kFALSE;
+       }
+       gAlice = fRunLoader->GetAliRun();
+  if(!gAlice) fRunLoader->LoadgAlice();
+       if(!gAlice){
+               Error("Open()", "Couldn't find gAlice object");
+               return kFALSE;
+       }
+       fTRD = (AliTRDv1*)gAlice->GetDetector("TRD");
+       if(!fTRD){
+               Error("Open()", "Couldn't find TRD");
+               return kFALSE;
+       }
+
+       return kTRUE;
+}
+
+//________________________________________________________
+void TRDLoader::Paint(Option_t *option)
+{
+       lpRE_i ichmb = fChildren.begin();
+       while(ichmb != fChildren.end()){
+               (dynamic_cast<TRDModule*>(*ichmb))->Paint(option);
+               ichmb++;
+       }
+}
+
+//________________________________________________________
+void TRDLoader::Unload()
+{
+       lpRE_i ichmb = fChildren.begin();
+       while(ichmb != fChildren.end()){
+               (dynamic_cast<TRDModule*>(*ichmb))->Reset();
+               ichmb++;
+       }
+}
+
+///////////////////////////////////////////////////////////
+/////////////   TRDLoaderEditor       /////////////////////
+///////////////////////////////////////////////////////////
+
+//________________________________________________________
+TRDLoaderEditor::TRDLoaderEditor(const TGWindow* p, Int_t width, Int_t height, UInt_t options, Pixel_t back) : TGedFrame(p, width, height, options | kVerticalFrame, back)
+{
+       MakeTitle("TRDLoader");
+       
+  fFile = 0x0;
+       fOpenFile = 0x0;
+       Int_t labelW = 42;
+  {
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+    TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
+    TGLabel* l = new TGLabel(g, "File: ");
+    g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
+    f->AddFrame(g);
+    fFile = new TGTextEntry(f);
+    fFile->SetWidth(140);
+    f->AddFrame(fFile);
+/*    
+               fFile->Connect("DoubleClicked()",
+                  "Alieve::TPCLoaderEditor", this, "FileSelect()");
+    fFile->Connect("TextChanged(const char *)",
+                  "Alieve::TPCLoaderEditor", this, "FileChanged()");
+*/    
+               fOpenFile = new TGTextButton(f, "Open");
+    f->AddFrame(fOpenFile);
+    fOpenFile->Connect("Clicked()",
+                      "Alieve::TRDLoaderEditor", this, "FileOpen()");
+               AddFrame(f);
+  }
+
+  fEvent = new RGValuator(this, "Event:", 110, 0);
+  fEvent->SetShowSlider(kFALSE);
+  fEvent->SetLabelWidth(labelW);
+  fEvent->SetNELength(6);
+  fEvent->Build();
+  fEvent->SetLimits(-1, 1000);
+  fEvent->SetToolTip("Current event number");
+/*  fEvent->Connect("ValueSet(Double_t)",
+                 "Alieve::TPCLoaderEditor", this, "DoEvent()");
+*/  
+       AddFrame(fEvent);
+
+
+       // "Chamber(s) selector" group frame
+       TGGroupFrame *fGroupFrame1974 = new TGGroupFrame(this,"Chamber(s) selector");
+       
+       TGVerticalFrame *fVerticalFrame1974 = new TGVerticalFrame(fGroupFrame1974,128,26,kVerticalFrame);
+
+       // horizontal frame
+       TGHorizontalFrame *fHorizontalFrame2020 = new TGHorizontalFrame(fVerticalFrame1974,128,26,kHorizontalFrame);
+       TGLabel *fLabel2170 = new TGLabel(fHorizontalFrame2020,"SM   ");
+       fLabel2170->SetTextJustify(kTextLeft | kTextCenterY);
+       fHorizontalFrame2020->AddFrame(fLabel2170, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       fSMNumber = new TGNumberEntry(fHorizontalFrame2020, (Int_t) -1, 5, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -1, 17);
+       fHorizontalFrame2020->AddFrame(fSMNumber, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsCenterY,2,2,2,2));
+
+       fVerticalFrame1974->AddFrame(fHorizontalFrame2020, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       // horizontal frame
+       TGHorizontalFrame *fHorizontalFrame2025 = new TGHorizontalFrame(fVerticalFrame1974,128,28,kHorizontalFrame);
+       TGLabel *fLabel2186 = new TGLabel(fHorizontalFrame2025,"Stack");
+       fLabel2186->SetTextJustify(kTextLeft | kTextCenterY);
+       fHorizontalFrame2025->AddFrame(fLabel2186, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fStackNumber = new TGNumberEntry(fHorizontalFrame2025, (Int_t) -1, 5, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -1, 4);
+       fHorizontalFrame2025->AddFrame(fStackNumber, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsCenterY,2,2,2,2));
+
+       fVerticalFrame1974->AddFrame(fHorizontalFrame2025, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       // horizontal frame
+       TGHorizontalFrame *fHorizontalFrame2030 = new TGHorizontalFrame(fVerticalFrame1974,128,26,kHorizontalFrame);
+       TGLabel *fLabel2208 = new TGLabel(fHorizontalFrame2030,"Plane");
+       fLabel2208->SetTextJustify(kTextLeft | kTextCenterY);
+       fHorizontalFrame2030->AddFrame(fLabel2208, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fPlaneNumber = new TGNumberEntry(fHorizontalFrame2030, (Int_t) -1, 5, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -1, 5);
+       fHorizontalFrame2030->AddFrame(fPlaneNumber, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsCenterY,2,2,2,2));
+
+       fVerticalFrame1974->AddFrame(fHorizontalFrame2030, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       
+       fGroupFrame1974->AddFrame(fVerticalFrame1974, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandY | kLHintsExpandX,2,2,2,2));
+
+       TGTextButton *fTextButton2037 = new TGTextButton(fGroupFrame1974,"Select");
+       fTextButton2037->SetTextJustify(36);
+       fTextButton2037->Resize(128,22);
+       fGroupFrame1974->AddFrame(fTextButton2037, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterX | kLHintsExpandY,2,2,2,2));
+       fTextButton2037->Connect("Clicked()",
+                                       "Alieve::TRDLoaderEditor", this, "AddChambers()");
+
+       fGroupFrame1974->SetLayoutManager(new TGHorizontalLayout(fGroupFrame1974));
+//     fGroupFrame1974->Resize(164,150);
+       AddFrame(fGroupFrame1974, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       
+       // "Data selector" group frame
+       TGGroupFrame *fGroupFrame1987 = new TGGroupFrame(this,"Data selector");
+       fLoadHits = new TGCheckButton(fGroupFrame1987,"  Hits");
+       fGroupFrame1987->AddFrame(fLoadHits, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fLoadDigits = new TGCheckButton(fGroupFrame1987,"  Digits");
+       fGroupFrame1987->AddFrame(fLoadDigits, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fLoadClusters = new TGCheckButton(fGroupFrame1987,"  Clusters");
+       fGroupFrame1987->AddFrame(fLoadClusters, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fLoadESDs = new TGCheckButton(fGroupFrame1987,"  Tracklets ");
+       fGroupFrame1987->AddFrame(fLoadESDs, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       fGroupFrame1987->SetLayoutManager(new TGVerticalLayout(fGroupFrame1987));
+//     fGroupFrame1987->Resize(164,116);
+       AddFrame(fGroupFrame1987, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       TGTextButton *fTextButton2004 = new TGTextButton(this,"Load");
+       fTextButton2004->SetTextJustify(36);
+       fTextButton2004->Resize(164,22);
+       AddFrame(fTextButton2004, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       fTextButton2004->Connect("Clicked()",
+                                       "Alieve::TRDLoaderEditor", this, "Load()");
+}
+
+//________________________________________________________
+TRDLoaderEditor::~TRDLoaderEditor()
+{}
+
+//_________________________________________________________
+void TRDLoaderEditor::SetModel(TObject* obj)
+{
+       fM = dynamic_cast<TRDLoader*>(obj);
+}
+
+//________________________________________________________
+void TRDLoaderEditor::AddChambers()
+{
+       fM->AddChambers((int)fSMNumber->GetNumber(),
+               (int)fStackNumber->GetNumber(),
+               (int)fPlaneNumber->GetNumber());
+}
+
+//________________________________________________________
+void TRDLoaderEditor::FileOpen()
+{
+  TGFileInfo fi;
+/*  fi.fIniDir    = StrDup(gSystem->DirName (fM->fFile));
+  fi.fFilename  = StrDup(gSystem->BaseName(fM->fFile));
+  fi.fFileTypes = tpcfiletypes;
+*/
+  new TGFileDialog(fClient->GetRoot(), gReve, kFDOpen, &fi);
+  if (!fi.fFilename) return;
+
+  fFile->SetToolTipText(gSystem->DirName (fi.fFilename));
+  fFile->SetText       (gSystem->BaseName(fi.fFilename));
+
+       fM->Open(gSystem->BaseName(fi.fFilename));
+}
+
+//________________________________________________________
+void TRDLoaderEditor::Load()
+{
+       fM->kLoadHits     = kFALSE;
+       fM->kLoadDigits   = kFALSE;
+       fM->kLoadClusters = kFALSE;
+       fM->kLoadTracks   = kFALSE;
+       if(fLoadHits->IsDown()) fM->kLoadHits = kTRUE;
+       if(fLoadDigits->IsDown()) fM->kLoadDigits = kTRUE;
+       if(fLoadClusters->IsDown()) fM->kLoadClusters = kTRUE;
+       if(fLoadESDs->IsDown()) fM->kLoadTracks = kTRUE;
+       
+       fM->GoToEvent((int)fEvent->GetEntry()->GetNumber());
+}
+
diff --git a/EVE/Alieve/TRDLoader.h b/EVE/Alieve/TRDLoader.h
new file mode 100644 (file)
index 0000000..341ea4e
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef ALIEVE_TRDLoader_H
+#define ALIEVE_TRDLoader_H
+
+////////////////////////////////////////////////////////////////////////
+//                                                                      // - ALIEVE implementation -
+// Loader for the TRD detector
+//    - TRDLoader - loader of TRD data (simulation + measured)
+//    - TRDLoaderEditor - UI
+//
+// by A.Bercuci (A.Bercuci@gsi.de)   Fri Oct 27 2006
+////////////////////////////////////////////////////////////////////////
+
+#ifndef REVE_RenderElement_H
+#include <Reve/RenderElement.h>
+#endif
+
+#ifndef ROOT_TNamed
+#include <TNamed.h>
+#endif
+
+#ifndef ROOT_TGedFrame
+#include <TGedFrame.h>
+#endif
+
+//#include <map>
+
+class AliRunLoader;
+class AliLoader;
+class AliTRDhit;
+class AliTRDv1;
+
+class TGTextButton;
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+class TGTextEntry;
+class TTree;
+namespace Reve {
+       class RGValuator;
+}
+namespace Alieve {
+       class TRDChamber;
+       enum DataTypes{
+               kHits = 0,
+               kDigits = 1,
+               kClusters = 2,
+               kESDs = 3 
+       };
+       class TRDLoader : public Reve::RenderElementListBase, public TNamed
+       {
+       friend class TRDLoaderEditor;
+       public:
+               TRDLoader(const Text_t* n="TRDLoader", const Text_t* t=0);
+               ~TRDLoader();
+
+       protected:
+               virtual void    AddChambers(const int sm=-1, const int stk=-1, const int ly=-1);
+
+               TRDChamber*     GetChamber(const int d);
+               Bool_t                  GoToEvent(const int ev);
+               Bool_t                  LoadClusters(TTree *tC);
+               Bool_t                  LoadDigits(TTree *tD);
+               Bool_t                  LoadHits(TTree *tH);
+               Bool_t                  LoadTracklets(TTree *tT);
+               Bool_t                  Open(const char *filename);
+               virtual void Paint(Option_t *option="");
+               void                            Unload();
+               
+       protected:
+               Bool_t kLoadHits, kLoadDigits, kLoadClusters, kLoadTracks;
+       
+       private:
+               AliRunLoader    *fRunLoader;
+               AliTRDv1                        *fTRD;
+               
+               ClassDef(TRDLoader, 1) // Alieve Loader class for the TRD detector
+       };
+
+
+       
+       class TRDLoaderEditor : public TGedFrame
+       {
+       public:
+               TRDLoaderEditor(const TGWindow* p=0, Int_t width = 170, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground());
+               ~TRDLoaderEditor();
+
+               virtual void    AddChambers();
+               virtual void    FileOpen();
+               virtual void    Load();
+               virtual void    SetModel(TObject* obj);
+               
+               
+       protected:
+               TRDLoader* fM;
+       TGTextEntry *fFile;
+               TGTextButton *fOpenFile;
+               Reve::RGValuator *fEvent;
+
+               TGNumberEntry *fSMNumber, *fStackNumber, *fPlaneNumber;
+               TGCheckButton *fLoadHits, *fLoadDigits, *fLoadClusters, *fLoadESDs;
+               
+               ClassDef(TRDLoaderEditor,1) // Editor for TRDLoader
+       };
+}
+#endif
diff --git a/EVE/Alieve/TRDModule.cxx b/EVE/Alieve/TRDModule.cxx
new file mode 100644 (file)
index 0000000..bb3baf3
--- /dev/null
@@ -0,0 +1,257 @@
+#include "TRDModule.h"
+#include "TRDModuleImp.h"
+
+#include "TGButton.h"
+#include "TGColorSelect.h"
+#include "TGNumberEntry.h"
+#include "TG3DLine.h"
+//#include "TColor.h"
+//#include "TMath.h"
+
+#include "Reve/RGTopFrame.h"
+#include "Reve/Track.h"
+
+
+using namespace Reve;
+using namespace Alieve;
+//using namespace std;
+
+ClassImp(TRDModule)
+ClassImp(TRDModuleEditor)
+
+//________________________________________________________
+TRDModule::TRDModule(const char *typ, const Int_t det) :
+  TNamed(Form("%s%03d", typ, det), ""), fDet(det)
+{
+       fLoadHits = kFALSE;
+       fRnrHits = kTRUE;
+       
+       fLoadDigits = kFALSE;
+       fRnrDigits = kTRUE;
+       fDigitsLog = kFALSE;
+       fDigitsBox = kFALSE;
+
+       fLoadRecPoints = kFALSE;
+       fRnrRecPoints = kTRUE;
+
+       fLoadTracklets = kFALSE;
+       fRnrTracklets = kTRUE;
+
+       kDigitsNeedRecompute = kTRUE;
+
+       fDigitsThreshold = 10;
+}
+
+
+
+///////////////////////////////////////////////////////////
+/////////////   TRDModuleEditor       /////////////////////
+///////////////////////////////////////////////////////////
+
+//________________________________________________________
+TRDModuleEditor::TRDModuleEditor(const TGWindow* p, Int_t width, Int_t height, UInt_t options, Pixel_t back) : TGedFrame(p, width, height, options | kVerticalFrame, back)
+{
+       MakeTitle("TRD Detector");
+       
+       // "Hits" group frame
+       TGGroupFrame *fGroupFrame615 = new TGGroupFrame(this,"Hits");
+       fDisplayHits = new TGCheckButton(fGroupFrame615,"Display");
+       fDisplayHits->SetToolTipText("Display hits attached to chamber");
+       fDisplayHits->SetState(kButtonDown);
+       fGroupFrame615->AddFrame(fDisplayHits, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fDisplayHits->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "UpdateChamber()");
+
+       // color select widget
+       ULong_t ColPar1;
+       gClient->GetColorByName("#ff00ff", ColPar1);
+       fHitsColor = new TGColorSelect(fGroupFrame615, ColPar1, -1);
+
+       fGroupFrame615->AddFrame(fHitsColor, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsCenterY,2,2,2,2));
+       fHitsColor->Connect("ColorSelected(Pixel_t)",
+                                       "Alieve::TRDModuleEditor", this, "UpdateHits(Pixel_t)");
+       
+       fGroupFrame615->SetLayoutManager(new TGVerticalLayout(fGroupFrame615));
+       AddFrame(fGroupFrame615, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       // "Digits" group frame
+       TGGroupFrame *fGroupFrame636 = new TGGroupFrame(this,"Digits");
+       TGVerticalFrame *fVerticalFrame538 = new TGVerticalFrame(fGroupFrame636,68,63,kVerticalFrame);
+       fDisplayDigits = new TGCheckButton(fVerticalFrame538,"Display");
+       fDisplayDigits->SetState(kButtonDown);
+       fDisplayDigits->SetToolTipText("Toggle display digits attached to chamber");
+       fVerticalFrame538->AddFrame(fDisplayDigits, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fDisplayDigits->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "UpdateChamber()");
+       fToggleLog = new TGCheckButton(fVerticalFrame538,"Log");
+       fToggleLog->SetState(kButtonUp);
+       fToggleLog->SetToolTipText("Toggle logarithmic representation of digits");
+       fVerticalFrame538->AddFrame(fToggleLog, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fToggleLog->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "ModifyDigitsView()");
+
+       fToggleBox = new TGCheckButton(fVerticalFrame538,"Box");
+       fToggleBox->SetState(kButtonUp);
+       fToggleBox->SetToolTipText("Toggle display digits as boxes");
+       fVerticalFrame538->AddFrame(fToggleBox, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fToggleBox->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "ModifyDigitsView()");
+       fGroupFrame636->AddFrame(fVerticalFrame538, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+   
+   TGVertical3DLine *fVertical3DLine773 = new TGVertical3DLine(fGroupFrame636,8,63);
+   fGroupFrame636->AddFrame(fVertical3DLine773, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsExpandY,2,2,2,2));
+        
+        // vertical frame
+       TGVerticalFrame *fVerticalFrame543 = new TGVerticalFrame(fGroupFrame636,81,47,kVerticalFrame);
+       fThreshold = new TGCheckButton(fVerticalFrame543, "Threshold");
+       fThreshold->SetToolTipText("Toggle threshold updating display");
+       fVerticalFrame543->AddFrame(fThreshold, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fThresValue = new TGNumberEntry(fVerticalFrame543, (Int_t)10, 5, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive, TGNumberFormat::kNELLimitMinMax, 0, 1024);
+       fThresValue->Connect("ValueSet(Long_t)",
+                 "Alieve::TRDModuleEditor", this, "SetThreshold(Long_t)");
+       fVerticalFrame543->AddFrame(fThresValue, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       fGroupFrame636->AddFrame(fVerticalFrame543, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
+
+       fGroupFrame636->SetLayoutManager(new TGHorizontalLayout(fGroupFrame636));
+       AddFrame(fGroupFrame636, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       // "Clusters" group frame
+       TGGroupFrame *fGroupFrame649 = new TGGroupFrame(this,"Clusters");
+       fDisplayClusters = new TGCheckButton(fGroupFrame649,"Display");
+       fDisplayClusters->SetToolTipText("Display clusters attached to chamber");
+       fGroupFrame649->AddFrame(fDisplayClusters, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fDisplayClusters->SetState(kButtonDown);
+       fDisplayClusters->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "UpdateChamber()");
+
+       // color select widget
+       ULong_t ColPar2;
+       gClient->GetColorByName("#ff00ff", ColPar2);
+       fClustersColor = new TGColorSelect(fGroupFrame649, ColPar2, -1);
+
+       fGroupFrame649->AddFrame(fClustersColor, new TGLayoutHints(kLHintsLeft | kLHintsCenterX | kLHintsTop | kLHintsCenterY,2,2,2,2));
+       fClustersColor->Connect("ColorSelected(Pixel_t)",
+                                       "Alieve::TRDModuleEditor", this, "UpdateClusters(Pixel_t)");
+
+       fGroupFrame649->SetLayoutManager(new TGVerticalLayout(fGroupFrame649));
+       AddFrame(fGroupFrame649, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+
+       // "Tracks" group frame
+       TGGroupFrame *fGroupFrame676 = new TGGroupFrame(this,"Tracklets");
+       fDisplayTracks = new TGCheckButton(fGroupFrame676,"Display");
+       fDisplayTracks->SetToolTipText("Display MCM tracklets attached to chamber");
+       fGroupFrame676->AddFrame(fDisplayTracks, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+       fDisplayTracks->SetState(kButtonDown);
+       fDisplayTracks->Connect("Clicked()",
+                                       "Alieve::TRDModuleEditor", this, "UpdateChamber()");
+
+       fGroupFrame676->SetLayoutManager(new TGVerticalLayout(fGroupFrame676));
+       AddFrame(fGroupFrame676, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsCenterY | kLHintsExpandX,2,2,2,2));
+}
+
+//________________________________________________________
+TRDModuleEditor::~TRDModuleEditor()
+{}
+
+//_________________________________________________________
+void TRDModuleEditor::SetModel(TObject* obj)
+{
+// Takes care to update UI state according to model state
+
+       fM = dynamic_cast<TRDModule*>(obj);
+       if(dynamic_cast<TRDNode*>(fM)) dynamic_cast<TRDNode*>(fM)->UpdateNode();
+       
+       if(fM->fLoadHits) fDisplayHits->SetState(fM->fRnrHits ? kButtonDown : kButtonUp);
+       else fDisplayHits->SetEnabled(kFALSE);
+               
+       if(fM->fLoadDigits){
+               fDisplayDigits->SetState(fM->fRnrDigits ? kButtonDown : kButtonUp);
+               fToggleLog->SetState(fM->fDigitsLog ? kButtonDown : kButtonUp);
+               fToggleBox->SetState(fM->fDigitsBox ? kButtonDown : kButtonUp);
+               fThresValue->SetIntNumber(fM->fDigitsThreshold);
+       } else {
+               fDisplayDigits->SetEnabled(kFALSE);
+               fToggleLog->SetEnabled(kFALSE);
+               fToggleBox->SetEnabled(kFALSE);
+       }
+       fThreshold->SetEnabled(fM->fLoadDigits);
+
+       
+       if(fM->fLoadRecPoints) fDisplayClusters->SetState(fM->fRnrRecPoints ? kButtonDown : kButtonUp);
+       else fDisplayClusters->SetEnabled(kFALSE);
+       
+       if(fM->fLoadTracklets) fDisplayTracks->SetState(fM->fRnrTracklets ? kButtonDown : kButtonUp);
+       else fDisplayTracks->SetEnabled(kFALSE);
+}
+
+//_________________________________________________________
+void TRDModuleEditor::ModifyDigitsView()
+{
+       fM->kDigitsNeedRecompute = kTRUE;
+       UpdateChamber();
+}
+
+//________________________________________________________
+void TRDModuleEditor::SetThreshold(Long_t tres)
+{
+       if(!fM->fLoadDigits) return;
+       tres = (tres == 0) ? (int)fThresValue->GetNumber():tres;
+       
+       fM->fDigitsThreshold = tres;
+       if(fThreshold->IsDown()) fM->kDigitsNeedRecompute = kTRUE;
+       UpdateChamber();
+}
+
+
+//_________________________________________________________
+void TRDModuleEditor::UpdateChamber()
+{
+//     Info("UpdateChamber()", "");
+
+       fM->fRnrHits = kFALSE;
+       if(fDisplayHits->IsDown()) fM->fRnrHits = kTRUE;
+       
+       fM->fRnrDigits = kFALSE;
+       if(fDisplayDigits->IsDown()){
+               fM->fRnrDigits = kTRUE;
+               if(fToggleLog->IsDown()) fM->fDigitsLog = kTRUE;
+               else  fM->fDigitsLog = kFALSE;
+               if(fToggleBox->IsDown()) fM->fDigitsBox = kTRUE;
+               else  fM->fDigitsBox = kFALSE;
+       }
+       
+       fM->fRnrRecPoints = kFALSE;
+       if(fDisplayClusters->IsDown()) fM->fRnrRecPoints = kTRUE;
+       
+       fM->fRnrTracklets = kFALSE;
+       if(fDisplayTracks->IsDown()) fM->fRnrTracklets = kTRUE;
+
+       if(dynamic_cast<TRDNode*>(fM)) (dynamic_cast<TRDNode*>(fM))->UpdateLeaves();
+
+       gReve->Redraw3D();
+}
+
+//_________________________________________________________
+void TRDModuleEditor::UpdateClusters(Pixel_t /*col*/)
+{
+//     Info("UpdateClusters()","");
+/*     
+       if(fM->fRecPoints){
+               fM->fRecPoints->SetMarkerColor(col ? fHitsColor->GetColor() : col);
+               gReve->Redraw3D();
+       }
+*/
+}
+
+//_________________________________________________________
+void TRDModuleEditor::UpdateHits(Pixel_t /*col*/)
+{
+//     Info("UpdateHits()","");
+/*     
+       if(fM->fHits){
+               fM->fHits->SetMarkerColor(col ? fClustersColor->GetColor() : col);
+               gReve->Redraw3D();
+       }
+*/
+}
diff --git a/EVE/Alieve/TRDModule.h b/EVE/Alieve/TRDModule.h
new file mode 100644 (file)
index 0000000..8dec85a
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef ALIEVE_TRDModule_H
+#define ALIEVE_TRDModule_H
+
+/////////////////////////////////////////////////////////////////////////
+//
+// - AliEVE implementation -
+// The common structure of a TRD module (SM, Stack or Chamber)
+//    - TRDModule - structure of TRD module for visualisation
+//    - TRDModuleEditor - UI
+//
+// by A.Bercuci (A.Bercuci@gsi.de)   Fri Oct 27 2006
+///////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TNamed
+#include <TNamed.h>
+#endif
+
+#ifndef ROOT_TGedFrame
+#include <TGedFrame.h>
+#endif
+
+class TObject;
+class TGWindow;
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+
+namespace Alieve {
+
+       class TRDModule : public TNamed
+       {
+       friend class TRDModuleEditor;
+       friend class TRDNode;
+       friend class TRDChamber;
+       public:
+               TRDModule(const char *typ="XXX", const Int_t id=0);
+               virtual ~TRDModule() {}
+       
+               virtual Int_t   GetID(){return fDet;}
+               virtual void    Paint(Option_t* option="")=0;
+               virtual void    Reset()=0;
+
+       protected:
+               // UI section
+               Bool_t  fLoadHits, fRnrHits;
+               Bool_t  fLoadDigits, fRnrDigits, fDigitsLog, fDigitsBox;
+               Bool_t  kDigitsNeedRecompute;
+
+               Bool_t  fLoadRecPoints, fRnrRecPoints;
+               Bool_t  fLoadTracklets, fRnrTracklets;
+               
+               Int_t fDet; // detector number
+               UShort_t        fDigitsThreshold; // digits threshold
+       ClassDef(TRDModule,1) // Structure holder for TRD chamber
+       };
+       
+
+       class TRDModuleEditor : public TGedFrame
+       {
+       public:
+               TRDModuleEditor(const TGWindow* p=0, Int_t width = 170, Int_t height = 30, UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground());
+               ~TRDModuleEditor();
+
+               virtual void SetModel(TObject* obj);
+
+               void    ModifyDigitsView();
+               void    SetThreshold(Long_t thres);
+               void    UpdateChamber();
+               void    UpdateClusters(Pixel_t);
+               void    UpdateHits(Pixel_t);
+       
+       protected:
+               TRDModule* fM;
+
+       private:
+               TGCheckButton *fDisplayHits;
+               TGColorSelect *fHitsColor;
+               TGCheckButton *fDisplayDigits, *fToggleLog, *fToggleBox, *fThreshold;
+               TGNumberEntry   *fThresValue;
+               TGCheckButton *fDisplayClusters;
+               TGColorSelect *fClustersColor;
+               TGCheckButton *fDisplayTracks;
+               
+       ClassDef(TRDModuleEditor,1) // Editor for TRDModule
+       };
+}
+
+#endif
diff --git a/EVE/Alieve/TRDModuleImp.cxx b/EVE/Alieve/TRDModuleImp.cxx
new file mode 100644 (file)
index 0000000..f919cc8
--- /dev/null
@@ -0,0 +1,410 @@
+#include "TRDModuleImp.h"
+#include "TRDData.h"
+
+#include "TMath.h"
+#include <TGListTree.h>
+
+#include "Reve/RGTopFrame.h"
+#include "Reve/Track.h"
+
+#include "AliRun.h"
+#include "AliTRDv1.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDCommonParam.h"
+#include "AliTRDpadPlane.h"
+#include "AliTRDdigit.h"
+#include "AliTRDhit.h"
+#include "AliTRDcluster.h"
+#include "AliTRDcalibDB.h"
+#include "AliTRDdataArrayI.h"
+#include "AliTRDmcmTracklet.h"
+
+
+
+using namespace Reve;
+using namespace Alieve;
+using namespace std;
+
+ClassImp(TRDChamber)
+ClassImp(TRDNode)
+
+//________________________________________________________
+TRDNode::TRDNode(const char *typ, const Int_t det) :
+  Reve::RenderElementListBase(), TRDModule(typ, det)
+{
+}
+
+//________________________________________________________
+void   TRDNode::Paint(Option_t* option)
+{
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               (dynamic_cast<TRDModule*>(*iter))->Paint(option);
+               iter++;
+       }
+}
+
+//________________________________________________________
+void   TRDNode::Reset()
+{
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               (dynamic_cast<TRDModule*>(*iter))->Reset();
+               iter++;
+       }
+}
+
+//________________________________________________________
+void TRDNode::Colapse()
+{
+       TGListTree *list = gReve->GetListTree();
+       TRDNode *node = 0x0;
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))) node->Colapse();
+               list->CloseItem(FindListTreeItem(list));
+               iter++;
+       }
+}
+
+//________________________________________________________
+void TRDNode::Expand()
+{
+       TGListTree *list = gReve->GetListTree();
+       TRDNode *node = 0x0;
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))) node->Expand();
+               list->OpenItem(FindListTreeItem(list));
+               iter++;
+       }
+}
+
+//________________________________________________________
+void TRDNode::EnableListElements()
+{
+       SetRnrElement(kTRUE);
+       TRDNode *node = 0x0;
+       TRDChamber *chmb = 0x0; 
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))){
+                       node->SetRnrElement(kTRUE);
+                       node->EnableListElements();
+               }
+               if((chmb = dynamic_cast<TRDChamber*>(*iter))) chmb->SetRnrElement(kTRUE);
+               iter++;
+       }
+       gReve->Redraw3D();
+}
+
+//________________________________________________________
+void TRDNode::DisableListElements()
+{
+       SetRnrElement(kFALSE);
+       TRDNode *node = 0x0;
+       TRDChamber *chmb = 0x0; 
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))){
+                       node->SetRnrElement(kFALSE);
+                       node->DisableListElements();
+               }
+               if((chmb = dynamic_cast<TRDChamber*>(*iter))) chmb->SetRnrElement(kFALSE);
+               iter++;
+       }
+       gReve->Redraw3D();
+}
+
+//________________________________________________________
+void TRDNode::UpdateLeaves()
+{
+       TRDModule *module;
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               module = dynamic_cast<TRDModule*>(*iter);
+               if(!module) continue;
+               
+               module->fRnrHits = fRnrHits;
+               module->fRnrDigits = fRnrDigits;
+               module->fDigitsLog = fDigitsLog;
+               module->fDigitsBox = fDigitsBox;
+               module->fDigitsThreshold = fDigitsThreshold;
+               module->kDigitsNeedRecompute = kDigitsNeedRecompute;
+               module->fRnrRecPoints = fRnrRecPoints;
+               module->fRnrTracklets = fRnrTracklets;
+               iter++;
+       }
+
+       TRDNode *node = 0x0;
+       iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))) node->UpdateLeaves();
+               iter++;
+       }
+}
+
+
+//________________________________________________________
+void TRDNode::UpdateNode()
+{
+//     Info("UpdateNode()", Form("%s", GetName()));
+       TRDNode *node = 0x0;
+       lpRE_i iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               if((node = dynamic_cast<TRDNode*>(*iter))) node->UpdateNode();
+               iter++;
+       }
+
+       Int_t score[11];
+       for(int i=0; i<11; i++) score[i] = 0;
+       TRDModule *module;
+       iter = fChildren.begin();
+       while(iter != fChildren.end()){
+               module = dynamic_cast<TRDModule*>(*iter);
+               if(!module) continue;
+               score[0] += (module->fLoadHits) ? 1 : 0;
+               score[1] += (module->fRnrHits) ? 1 : 0;
+               
+               score[2] += (module->fLoadDigits) ? 1 : 0;
+               score[3] += (module->fRnrDigits) ? 1 : 0;
+               score[4] += (module->fDigitsLog) ? 1 : 0;
+               score[5] += (module->fDigitsBox) ? 1 : 0;
+               score[6] += (module->kDigitsNeedRecompute) ? 1 : 0;
+
+               score[7] += (module->fLoadRecPoints) ? 1 : 0;
+               score[8] += (module->fRnrRecPoints) ? 1 : 0;
+
+               score[9] += (module->fLoadTracklets) ? 1 : 0;
+               score[10] += (module->fRnrTracklets) ? 1 : 0;
+               iter++;
+       }
+
+       Int_t size = fChildren.size(); 
+       fLoadHits      = (score[0] > 0) ? kTRUE : kFALSE;
+       fRnrHits       = (score[1] == size) ? kTRUE : kFALSE;
+
+       fLoadDigits    = (score[2] > 0) ? kTRUE : kFALSE;
+       fRnrDigits     = (score[3] == size) ? kTRUE : kFALSE;
+       fDigitsLog     = (score[4] == size) ? kTRUE : kFALSE;
+       fDigitsBox     = (score[5] == size) ? kTRUE : kFALSE;
+       kDigitsNeedRecompute = (score[6] == size) ? kTRUE : kFALSE;
+
+       fLoadRecPoints = (score[7] > 0) ? kTRUE : kFALSE;
+       fRnrRecPoints  = (score[8] == size) ? kTRUE : kFALSE;
+
+       fLoadTracklets = (score[9] > 0) ? kTRUE : kFALSE;
+       fRnrTracklets  = (score[10] == size) ? kTRUE : kFALSE;
+}
+
+
+///////////////////////////////////////////////////////////
+/////////////        TRDChamber       /////////////////////
+///////////////////////////////////////////////////////////
+
+//________________________________________________________
+TRDChamber::TRDChamber(const Int_t det) :
+  Reve::RenderElement(), TRDModule("Chmb", det)
+{
+  //
+  // Constructor
+  //
+       fDigits    = 0x0;
+       fHits      = 0x0;
+       fRecPoints = 0x0;
+       fTracklets = 0x0;
+       
+       fPadPlane = 0x0;
+       fGeo      = 0x0;        
+}
+
+//________________________________________________________
+void TRDChamber::Init()
+{
+       if(!gAlice) return;
+
+       AliTRDv1 *trd = (AliTRDv1*)gAlice->GetDetector("TRD");
+  fGeo = trd->GetGeometry();
+       fPla = fGeo->GetPlane(fDet);
+       timeMax = 22;
+       fX0 = fGeo->GetTime0(fPla);
+       
+       AliTRDCommonParam *parcom = AliTRDCommonParam::Instance();
+       fPadPlane = parcom->GetPadPlane(fPla,fGeo->GetChamber(fDet));
+       rowMax = fPadPlane->GetNrows();
+       colMax = fPadPlane->GetNcols();
+       
+       AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
+       samplingFrequency = calibration->GetSamplingFrequency();
+}
+
+//________________________________________________________
+TRDChamber::TRDChamber(const TRDChamber &mod) :
+  Reve::RenderElement(), TRDModule("Chmb", mod.fDet)
+{
+  //
+  // Copy constructor
+  //
+       SetMainColor(mod.GetMainColor());
+
+       if(mod.fDigits) {}
+       if(mod.fHits) {}
+       if(mod.fRecPoints){} 
+}
+
+//________________________________________________________
+TRDChamber& TRDChamber::operator=(const TRDChamber &mod)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &mod) {
+    fDet    = mod.fDet;
+               if(mod.fDigits) {}
+               if(mod.fHits) {}
+               if(mod.fRecPoints){} 
+  }
+  return *this;
+}
+
+//________________________________________________________
+void TRDChamber::LoadClusters(TObjArray *clusters)
+{
+  //
+  // Draw clusters
+  //
+       
+       if(!fRecPoints){
+               fRecPoints = new TRDHits("clusters");
+               fRecPoints->SetMarkerSize(1.);
+               fRecPoints->SetMarkerStyle(24);
+               fRecPoints->SetMarkerColor(6);
+       }
+       if(!fGeo) Init();
+
+       Float_t q, z0;
+  Double_t cloc[3], cglo[3];
+       
+       z0 = fGeo->GetTime0(fPla);      
+       AliTRDcluster *c=0x0;
+       for(int iclus=0; iclus<clusters->GetEntriesFast(); iclus++){
+               c = (AliTRDcluster*)clusters->UncheckedAt(iclus);
+               cloc[2] = c->GetZ(); //x
+               cloc[1] = c->GetY(); //y
+               cloc[0] = z0 - c->GetX(); //z
+               q = c->GetQ();
+               fGeo->RotateBack(fDet,cloc,cglo);
+               fRecPoints->SetNextPoint(cglo[0], cglo[1], cglo[2]);
+               fRecPoints->SetPointId(this);
+       }
+       fLoadRecPoints = kTRUE;
+}
+
+//________________________________________________________
+void TRDChamber::LoadDigits(AliTRDdataArrayI *digits)
+{
+  //
+  // Draw digits
+  //
+
+       if(!fPadPlane) Init();
+       if(!fDigits) fDigits = new TRDDigits(this);
+       else fDigits->Reset();
+       
+       fDigits->SetData(digits);
+       fLoadDigits = kTRUE;
+}
+
+//________________________________________________________
+void TRDChamber::AddHit(AliTRDhit *hit)
+{
+  //
+  // Draw hits
+  //
+       if(!fHits){
+               fHits = new TRDHits("hits");
+               fHits->SetMarkerSize(.1);
+               fHits->SetMarkerColor(2);
+       }
+       fHits->SetNextPoint(hit->X(), hit->Y(), hit->Z());
+       fHits->SetPointId(this);
+       fLoadHits = kTRUE;
+}
+
+//________________________________________________________
+void TRDChamber::LoadTracklets(TObjArray *tracks)
+{
+  //
+  // Draw tracks
+  //
+       if(!fTracklets){
+               fTracklets = new std::vector<Reve::Track*>;
+       }
+       
+       if(!fGeo) Init();
+       
+       AliTRDmcmTracklet *trk = 0x0;
+       Double_t cloc[3], cglo[3];
+       for(int itrk=0; itrk<tracks->GetEntries();itrk++){
+               trk = (AliTRDmcmTracklet*)tracks->At(itrk);
+               trk->MakeTrackletGraph(fGeo,.5);
+               fTracklets->push_back(new Reve::Track());
+               fTracklets->back()->SetLineColor(4);
+               
+               cloc[0] = trk->GetTime0(); // x0
+               cloc[1] = trk->GetOffset(); // y0
+               cloc[2] = trk->GetRowz(); // z
+         fGeo->RotateBack(fDet,cloc,cglo);
+               fTracklets->back()->SetNextPoint(cglo[0], cglo[1], cglo[2]);
+               
+               cloc[0] += 3.7; // x1
+               cloc[1] += TMath::Tan(trk->GetSlope()*TMath::Pi()/180.) * 3.7; // y1
+         fGeo->RotateBack(fDet,cloc,cglo);
+               fTracklets->back()->SetNextPoint(cglo[0], cglo[1], cglo[2]);
+       }
+       fLoadTracklets = kTRUE;
+}
+
+//____________________________________________________
+void   TRDChamber::Paint(Option_t* option)
+{
+/*     Info("Paint()", Form("%s", GetName()));*/
+       if(!fRnrElement) return;
+       if(fDigits && fRnrDigits){
+               if(kDigitsNeedRecompute){
+                       fDigits->SetShow(fDigitsLog, fDigitsBox);
+                       fDigits->SetThreshold(fDigitsThreshold);
+                       fDigits->ComputeRepresentation();
+                       kDigitsNeedRecompute = kFALSE;
+               }
+               fDigits->Paint(option);
+       }
+       if(fRecPoints && fRnrRecPoints) fRecPoints->GetObject()->Paint(option);
+       if(fHits && fRnrHits) fHits->GetObject()->Paint(option);
+       if(fTracklets && fRnrTracklets){
+               for(vector<Reve::Track*>::iterator i=fTracklets->begin(); i != fTracklets->end(); ++i) (*i)->Paint(option);
+       }
+}
+
+//________________________________________________________
+void   TRDChamber::Reset()
+{
+       if(fHits){
+               fHits->Reset();
+               fLoadHits = kFALSE;
+       }
+       if(fDigits){
+               fDigits->Reset();
+               fLoadDigits = kFALSE;
+       }
+       if(fRecPoints){
+               fRecPoints->Reset();
+               fLoadRecPoints = kFALSE;
+       }
+       if(fTracklets){
+               fTracklets->clear();
+               fLoadTracklets = kFALSE;
+       }
+}
+
diff --git a/EVE/Alieve/TRDModuleImp.h b/EVE/Alieve/TRDModuleImp.h
new file mode 100644 (file)
index 0000000..fae15c4
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef ALIEVE_TRDModuleImp_H
+#define ALIEVE_TRDModuleImp_H
+
+/////////////////////////////////////////////////////////////////////////
+//
+// Implementation of TRDModule:
+//    - TRDChamber - Data holder
+//    - TRDNode    - Node structure 
+//
+// by A.Bercuci (A.Bercuci@gsi.de)   Fri Oct 27 2006
+/////////////////////////////////////////////////////////////////////////
+
+#ifndef REVE_RenderElement_H
+#include <Reve/RenderElement.h>
+#endif
+
+#ifndef ALIEVE_TRDModule_H
+#include "TRDModule.h"
+#endif
+
+class AliTRDpadPlane;
+class AliTRDgeometry;
+class AliTRDhit;
+class AliTRDdataArrayI;
+class TObjArray;
+
+namespace Reve {
+       class Track;
+}
+namespace Alieve {
+       class TRDHits;
+       class TRDDigits;
+
+       class TRDChamber : public Reve::RenderElement, public TRDModule
+       {
+       friend class TRDDigits;
+       public:
+       
+               TRDChamber(const Int_t det=0);
+               virtual ~TRDChamber() {}
+       
+               TRDChamber(const TRDChamber&);
+               TRDChamber& operator=(const TRDChamber&);
+               void    Init();
+               
+               void    AddHit(AliTRDhit *hit);
+               void    LoadClusters(TObjArray *cs);
+               void    LoadDigits(AliTRDdataArrayI *digits);
+               void    LoadTracklets(TObjArray *ts);
+               void    Paint(Option_t* option="");
+               void    Reset();
+               
+       protected:
+               TRDDigits       *fDigits;   // digits representation
+               TRDHits         *fHits;     // hits representation
+               TRDHits         *fRecPoints;// cluster representation
+               std::vector<Reve::Track*> *fTracklets; // mcm tracklets
+
+               // data representation section
+               Int_t           rowMax; // number of rows for this pad plane
+       Int_t           colMax; // number of columns for this pad plane
+       Int_t           timeMax; // number of timebins
+               Float_t samplingFrequency; // sampling frequency
+               Float_t fX0; // radial distance from vertex to the chamber
+               Int_t           fPla; // detector plane
+               AliTRDpadPlane *fPadPlane; // pad plane object
+               AliTRDgeometry *fGeo; // TRD geometry
+       
+       ClassDef(TRDChamber,1) // Holder for TRD chamber data
+       };
+
+       
+       class TRDNode : public Reve::RenderElementListBase, public TRDModule
+       {
+       public:
+               TRDNode(const char *typ, const Int_t det=0);
+               void    Paint(Option_t* option="");
+               void    Reset();
+
+               void    Colapse(); // *MENU*
+               void    Expand(); // *MENU*
+               void    EnableListElements(); // *MENU*
+               void    DisableListElements(); // *MENU*
+               void    UpdateLeaves();
+               void    UpdateNode();
+               
+               lpRE_i begin(){return fChildren.begin();}
+               lpRE_i end(){return fChildren.end();}
+       
+       ClassDef(TRDNode, 1)
+       };
+}
+
+#endif