]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New files for visualization of ITS scaled digits.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Mar 2007 15:22:04 +0000 (15:22 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 22 Mar 2007 15:22:04 +0000 (15:22 +0000)
EVE/Alieve/ITSScaledModule.cxx [new file with mode: 0644]
EVE/Alieve/ITSScaledModule.h [new file with mode: 0644]
EVE/Alieve/ITSScaledModuleEditor.cxx [new file with mode: 0644]
EVE/Alieve/ITSScaledModuleEditor.h [new file with mode: 0644]

diff --git a/EVE/Alieve/ITSScaledModule.cxx b/EVE/Alieve/ITSScaledModule.cxx
new file mode 100644 (file)
index 0000000..2512b73
--- /dev/null
@@ -0,0 +1,346 @@
+// $Header$
+
+#include "ITSScaledModule.h"
+
+#include <AliITSdigitSPD.h>
+#include <AliITSdigitSDD.h>
+#include <AliITSdigitSSD.h>
+
+using namespace Reve;
+using namespace Alieve;
+
+DigitScaleInfo*  ITSScaledModule::fgDigitScaleInfo = 0;
+
+//______________________________________________________________________
+// DigitScaleInfo
+//
+ClassImp(DigitScaleInfo)
+
+DigitScaleInfo::DigitScaleInfo():
+  fScale(1),
+  fStatType (ST_Average),
+  fAutoUpdatePalette(kTRUE)
+{
+}
+
+void DigitScaleInfo::ScaleChanged(Int_t s)
+{
+    fScale = s;
+    Emit("ScaleChanged(Int_t)",fScale);
+}
+
+void DigitScaleInfo::StatTypeChanged(Int_t t)
+{
+    fStatType = t;
+    Emit("StatTypeChanged(Int_t)",fStatType);
+}
+
+//______________________________________________________________________
+// DigitScaleInfo
+//
+ScaledDigit::ScaledDigit():
+  TObject(),
+  N(0),
+  sum(0), sqr_sum(0),
+  min_i(-1), min_j(-1), max_i(-1), max_j(-1)
+{
+}
+
+ScaledDigit::ScaledDigit(Int_t di, Int_t dj):
+  TObject(),
+  N(0),
+  sum(0), sqr_sum(0),
+  min_i(di), min_j(dj), max_i(di), max_j(dj)
+{
+}
+
+void ScaledDigit::Dump() const
+{
+  printf("N %d, sum %f, sqr_sum %f",N, sum, sqr_sum);
+}
+
+//______________________________________________________________________
+// ITSScaledModule
+//
+
+ClassImp(ITSScaledModule)
+
+ITSScaledModule::ITSScaledModule(Int_t gid, ITSDigitsInfo* info):
+  ITSModule("ITSScaledModule", "ITSScaledModule"),
+  fNx(-1),
+  fNz(-1),
+  fNCx(-1),
+  fNCz(-1)
+{
+  if(fgDigitScaleInfo == 0) 
+  {
+    fgDigitScaleInfo = new DigitScaleInfo();
+  } 
+
+  fgDigitScaleInfo->IncRefCount(this);
+  fgDigitScaleInfo->Connect("ScaleChanged(Int_t)", "Alieve::ITSScaledModule", this,"LoadQuads()");
+  fgDigitScaleInfo->Connect("StatTypeChanged(Int_t)", "Alieve::ITSScaledModule", this,"SetQuadValues()");
+  SetOwnIds(kTRUE);
+
+  SetDigitsInfo(info);
+  SetID(gid);
+}
+
+ITSScaledModule::~ITSScaledModule()
+{
+  fgDigitScaleInfo->DecRefCount();
+}
+
+/**************************************************************************/
+
+void ITSScaledModule::LoadQuads()
+{
+  // Here we still use 'z' for the name of axial coordinates.
+  // The transforamtion matrix aplied rotates y -> z.
+  // We need this as QuadSet offers optimized treatment for
+  // quads in the x-y plane.
+
+  TClonesArray *digits;
+  Float_t       x, z, zo, dpx, dpz; // orig cells size, pos
+  Int_t         i, j, ndigits;   // orig cells idx
+  Int_t         c1, c2;          // original coordinates
+
+  Int_t id;
+  map<Int_t, Int_t> dmap;
+  map<Int_t, Int_t>::iterator miter;
+  digits  = fInfo->GetDigits(fID, fDetID);
+  ndigits = digits->GetEntriesFast();
+
+  ScaledDigit* sd;
+  Int_t scale = fgDigitScaleInfo->GetScale() -1;
+  switch(fDetID)
+  {
+    case 0: 
+    { 
+      // SPD
+      Reset(QT_RectangleXZFixedY, kFALSE, 32);
+
+      fNCz = fInfo->fSPDScaleZ[scale];
+      fNCx = fInfo->fSPDScaleX[scale];
+      fNz  = Int_t(fInfo->fSegSPD->Npz()/fNCz);
+      fNx  = Int_t(fInfo->fSegSPD->Npx()/fNCx);
+      dpz = 2*fDz/fNz;  
+      dpx = 2*fDx/fNx;
+      //printf("SPD orig cells (%d, %d) (%d, %d)\n", fInfo->fSegSPD->Npx(), fInfo->fSegSPD->Npz(), Nx, Nz);
+
+      AliITSdigitSPD *od ;
+      for (Int_t k=0; k<ndigits; ++k)
+      {
+       od = (AliITSdigitSPD*) digits->UncheckedAt(k);
+
+       fInfo->GetSPDLocalZ(od->GetCoord1(),zo);
+        c1 = od->GetCoord1(); c2 = od->GetCoord2();
+       i = Int_t((zo+fDz)/dpz);
+       j = Int_t((od->GetCoord2()*fNx)/fInfo->fSegSPD->Npx());
+       id = j*fNx + i;
+        miter = dmap.find(id);
+       if(miter == dmap.end())
+       {       
+          dmap[id] = fPlex.Size();
+          z = dpz*(i) - fDz;
+          x = dpx*(j) - fDx;
+          AddQuad(x, z, dpx, dpz);
+          sd = new ScaledDigit(c1, c2);
+         QuadId(sd);
+       }
+        else 
+       {
+         sd = dynamic_cast<ScaledDigit*>(GetId(miter->second));
+          if(c1 < sd->min_i) 
+           sd->min_i = c1;
+         else if( c1 > sd->max_i)
+            sd->max_i = c1;
+       
+          if(c2 < sd->min_j) 
+           sd->min_j = c2;
+         else if( c2 > sd->max_j)
+           sd->max_j = c2;
+       }
+         
+       sd->N++;
+       sd->sum  += od->GetSignal();
+       sd->sqr_sum += od->GetSignal()*od->GetSignal();
+      }
+      break;
+    }
+    case 1: 
+    { 
+      // SDD
+      Reset(QT_RectangleXZFixedY, kFALSE, 32);
+
+      fNCz = fInfo->fSDDScaleZ[scale];
+      fNCx = fInfo->fSDDScaleX[scale];   
+      fNz  = Int_t(fInfo->fSegSDD->Npz()/fNCz);
+      fNx  = Int_t(fInfo->fSegSDD->Npx()/fNCx);
+      dpz = 2*fDz/fNz;
+      dpx = 2*fDx/fNx;
+
+      AliITSdigitSDD *od=0;
+      for (Int_t k=0; k<ndigits; k++) {
+       od=(AliITSdigitSDD*)digits->UncheckedAt(k);
+       fInfo->fSegSDD->DetToLocal(od->GetCoord2(), od->GetCoord1(),x,z);
+       z+= fDz;
+       x+= fDx;
+       i = Int_t(z/dpz);
+       j = Int_t(x/dpx);
+       //printf("Mod %d coord %d,%d out of %d,%d :: ORIG coord %d,%d out of %d,%d \n",fID,
+       //       i,j,Nz,Nx,od->GetCoord1(),od->GetCoord2(),fInfo->fSegSDD->Npz(),fInfo->fSegSDD->Npx());
+
+       id = j*fNx + i;
+       c1 = od->GetCoord1(); c2 = od->GetCoord2();
+       miter = dmap.find(id);
+       if(miter == dmap.end())
+       {       
+         dmap[id] = fPlex.Size();
+         z = dpz*(i) - fDz;
+         x = dpx*(j) - fDx;
+         AddQuad(x, z, dpx, dpz);
+         sd = new ScaledDigit(od->GetCoord1(),od->GetCoord2());
+         QuadId(sd);
+       }
+       else 
+       {
+         sd = dynamic_cast<ScaledDigit*>(GetId(miter->second));
+         if(c1 < sd->min_i) 
+           sd->min_i = c1;
+         else if( c1 > sd->max_i)
+           sd->max_i = c1;
+       
+         if(c2 < sd->min_j) 
+           sd->min_j = c2;
+         else if( c2 > sd->max_j)
+           sd->max_j = c2;
+       }
+       sd->N++;
+       sd->sum  += od->GetSignal();
+       sd->sqr_sum += od->GetSignal()*od->GetSignal();
+      }
+      break;
+    }  
+    case 2: 
+    { 
+      // SSD  
+      Reset(QT_LineXZFixedY, kFALSE, 32);
+
+      AliITSsegmentationSSD* seg = fInfo->fSegSSD; 
+      Float_t ap, an; // positive/negative angles -> offsets
+      seg->Angles(ap, an);
+      ap =   TMath::Tan(ap) * fDz;
+      an = - TMath::Tan(an) * fDz;
+
+      fNCx  = fInfo->fSSDScale[scale];   
+      fNz  = 1;
+      fNx  = Int_t(fInfo->fSegSSD->Npx()/fNCx);
+      dpz = 2*fDz/fNz;
+      dpx = 2*fDx/fNx;
+
+      AliITSdigitSSD *od=0;
+      for (Int_t k=0; k<ndigits; k++) {
+       od=(AliITSdigitSSD*)digits->UncheckedAt(k);
+       if(od->GetCoord1() == 1) 
+         i = 1; // p side
+       else 
+         i= -1; // n side
+       j = Int_t(od->GetCoord2()/fNCx);
+       c1 = od->GetCoord1(); c2 = od->GetCoord2();
+       id = j*i; 
+
+       miter = dmap.find(id);
+       ScaledDigit* sd;
+       if(miter == dmap.end())
+       {       
+         // printf("orig digit %d,%d scaled %d,%d \n",od->GetCoord1(),od->GetCoord2(),i,j);
+         dmap[id] = fPlex.Size();
+         z = dpz*(i) - fDz;
+         x = dpx*(j) - fDx;
+         Float_t a = ( od->GetCoord1() == 1) ? ap : an;
+         AddLine(x-a, -fDz, 2*a, 2*fDz);
+
+         sd = new ScaledDigit(c1, c2);
+         QuadId(sd);
+       }
+       else 
+       {
+         sd = dynamic_cast<ScaledDigit*>(GetId(miter->second)); 
+         if(c1 < sd->min_i) 
+           sd->min_i = c1;
+         else if( c1 > sd->max_i)
+           sd->max_i = c1;
+       
+         if(c2 < sd->min_j) 
+           sd->min_j = c2;
+         else if( c2 > sd->max_j)
+           sd->max_j = c2;
+       }
+       sd->N++;
+       sd->sum  += od->GetSignal();
+       sd->sqr_sum += od->GetSignal()*od->GetSignal();
+      } // for digits
+      break;
+    } // end case 2
+  } // end switch
+
+  SetQuadValues();
+  RefitPlex();
+}
+
+/**************************************************************************/
+
+void ITSScaledModule::SetQuadValues()
+{
+  Int_t N = fPlex.Size();
+  for (Int_t i = 0 ; i< N; i++)
+  {
+    ScaledDigit* sd = dynamic_cast<ScaledDigit*>(GetId(i));
+    Int_t v = 0;
+    switch(fgDigitScaleInfo->GetStatType()) {
+      case DigitScaleInfo::ST_Occup:   v = sd->N;   break;
+      case DigitScaleInfo::ST_Average: v = Int_t(sd->sum/(1.* sd->N)); break;
+      case DigitScaleInfo::ST_Rms:     v = Int_t(TMath::Sqrt(sd->sqr_sum)/(1.*sd->N)); break;    
+    }
+    QuadBase* qb = GetQuad(i);
+    qb->fValue = v;
+  }
+}
+
+/**************************************************************************/
+
+void  ITSScaledModule::QuadSelected(Int_t idx)
+{
+  // Override control-click from QuadSet
+  printf("ITSScaledModule::QuadSelected "); Print();
+
+  QuadBase* qb  = GetQuad(idx);
+  TObject* obj  = qb->fId.GetObject();
+  ScaledDigit* sd = dynamic_cast<ScaledDigit*>(obj);
+  TClonesArray *digits = fInfo->GetDigits(fID, fDetID);
+  Int_t ndigits = digits->GetEntriesFast();
+
+  printf("%d digits in cell scaleX = %d,  scaleZ = %d \n", sd->N, fNCx, fNCz);
+
+  Int_t il = 0;
+  for(Int_t k=0; k<ndigits; k++) 
+  {
+    AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
+
+    if(d->GetCoord1()>=sd->min_i && d->GetCoord1()<=sd->max_i && 
+       d->GetCoord2()>=sd->min_j && d->GetCoord2()<=sd->max_j) 
+    {
+      printf("%3d, %3d: %3d", d->GetCoord1(), d->GetCoord2(), d->GetSignal());
+      printf(" | ");
+      il++;
+      if(il>5) {
+       printf("\n");
+       il = 0;
+      }
+    }
+  }
+  if(il) printf("\n");
+}
diff --git a/EVE/Alieve/ITSScaledModule.h b/EVE/Alieve/ITSScaledModule.h
new file mode 100644 (file)
index 0000000..d6f27c8
--- /dev/null
@@ -0,0 +1,98 @@
+// $Header$
+
+#ifndef ALIEVE_ITSScaledModule_H
+#define ALIEVE_ITSScaledModule_H
+
+#include <Reve/Reve.h>
+#include <Alieve/ITSModule.h>
+
+#include <TQObject.h>
+
+namespace Alieve {
+
+/**************************************************************************/
+// DigitScaleInfo
+/**************************************************************************/
+
+class DigitScaleInfo : public TQObject, public Reve::ReferenceBackPtr
+{
+public:
+  enum StatType_e { ST_Occup, ST_Average, ST_Rms };
+  
+  Int_t            fScale;    
+  Int_t            fStatType;
+
+  Bool_t           fAutoUpdatePalette;
+private:
+  DigitScaleInfo(const DigitScaleInfo&);            // Not implemented
+  DigitScaleInfo& operator=(const DigitScaleInfo&); // Not implemented
+
+public:
+  DigitScaleInfo();
+  virtual ~DigitScaleInfo(){}
+    
+  Int_t            GetScale() {return fScale;}
+  void             ScaleChanged(Int_t s); //*SIGNAL*
+
+  Int_t            GetStatType() {return fStatType;}
+  void             StatTypeChanged(Int_t t);  //*SIGNAL*
+
+  ClassDef(DigitScaleInfo, 1);
+};
+
+/**************************************************************************/
+// ScaledDigit
+/**************************************************************************/
+
+class ScaledDigit : public TObject
+{
+public:
+  Int_t N;
+  Float_t sum;
+  Float_t sqr_sum;
+  Int_t min_i,min_j;
+  Int_t max_i,max_j;
+
+  ScaledDigit();
+  ScaledDigit(Int_t di, Int_t dj);
+  
+  virtual void Dump() const;
+}; 
+
+/**************************************************************************/
+// ITSScaledModule
+/**************************************************************************/
+
+class ITSScaledModule : public ITSModule
+{
+  friend class ITSSDSubEditor;
+private:
+  map<Int_t, ScaledDigit> fDigitsMap;  
+  
+  ITSScaledModule(const ITSScaledModule&);            // Not implemented
+  ITSScaledModule& operator=(const ITSScaledModule&); // Not implemented
+
+protected:
+  Int_t       fNx;  //  per module 
+  Int_t       fNz;
+
+  Int_t       fNCx;  // per cell
+  Int_t       fNCz;
+
+public:
+  ITSScaledModule(Int_t gid, ITSDigitsInfo* info);
+  virtual ~ITSScaledModule();
+
+  virtual void QuadSelected(Int_t idx);
+
+  virtual void LoadQuads();
+  void         SetQuadValues();
+
+  static Alieve::DigitScaleInfo*  fgDigitScaleInfo;
+
+  ClassDef(ITSScaledModule, 1);
+}; // endclass ITSScaledModule
+
+}
+
+#endif
diff --git a/EVE/Alieve/ITSScaledModuleEditor.cxx b/EVE/Alieve/ITSScaledModuleEditor.cxx
new file mode 100644 (file)
index 0000000..74dc85b
--- /dev/null
@@ -0,0 +1,232 @@
+// $Header$
+
+#include "ITSScaledModuleEditor.h"
+#include <Alieve/ITSScaledModule.h>
+#include <Reve/ZTransEditor.h>
+#include <Reve/RGValuators.h>
+
+#include <TVirtualPad.h>
+#include <TColor.h>
+#include <TMath.h>
+
+#include <TGedEditor.h>
+#include <TGLabel.h>
+#include <TGButton.h>
+#include <TGNumberEntry.h>
+#include <TGColorSelect.h>
+#include <TGComboBox.h>
+
+using namespace Reve;
+using namespace Alieve;
+
+//______________________________________________________________________
+// SDPaletteSubEditor
+//
+ITSSDSubEditor::ITSSDSubEditor(const TGWindow* p) :
+  RGBAPaletteSubEditor(p),
+  fModule(0),
+  fScale(0),
+  fStatistic(0),
+  fInfoLabel0(0),
+  fInfoLabel1(0),
+  fInfoLabel2(0)
+{
+  // Create widgets
+  {
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+    TGLabel *l = new TGLabel(f, "Scale:");
+    f->AddFrame(l, new TGLayoutHints(kLHintsTop | kLHintsCenterY, 0, 5, 1, 1));
+    fScale = new TGNumberEntry(f, 0, 2, -1,
+                              TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive,
+                              TGNumberFormat::kNELLimitMinMax, 1, 5);
+    fScale->GetNumberEntry()->SetToolTipText("Set cell size.");
+    f->AddFrame(fScale, new TGLayoutHints(kLHintsLeft, 1, 7, 1, 1));
+    fScale->Associate(f);
+    fScale->Connect("ValueSet(Long_t)", "Alieve::ITSSDSubEditor", this, "DoScale()");
+    
+    TGLabel* lab = new TGLabel(f, "Statistic:");
+    f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 2, 1, 2));
+    fStatistic = new TGComboBox(f);
+    fStatistic->AddEntry("Occup", 0);
+    fStatistic->AddEntry("Average", 1);
+    fStatistic->AddEntry("RMS", 2);
+    TGListBox* lb = fStatistic->GetListBox();
+    lb->Resize(lb->GetWidth(), 3*16);
+    fStatistic->Resize(74, 20);
+    fStatistic->Connect("Selected(Int_t)", "Alieve::ITSSDSubEditor", this, "DoStatType(Int_t)");
+    f->AddFrame(fStatistic, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
+    AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
+  }
+
+  Int_t lp = 2;
+  fInfoLabel0 = new TGLabel(this);
+  fInfoLabel0->SetTextJustify(kTextLeft);
+  AddFrame(fInfoLabel0, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
+                                        lp, 0, 8, 0));
+
+  fInfoLabel1 = new TGLabel(this);
+  fInfoLabel1->SetTextJustify(kTextLeft);
+  AddFrame(fInfoLabel1, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
+                                        lp, 0, 2, 0));
+
+  fInfoLabel2 = new TGLabel(this);
+  fInfoLabel2->SetTextJustify(kTextLeft);
+  AddFrame(fInfoLabel2, new TGLayoutHints(kLHintsLeft|kLHintsExpandX,
+                                        lp, 0, 2, 0));
+}
+
+/**************************************************************************/
+
+void ITSSDSubEditor::SetModel(ITSScaledModule* mod)
+{
+  fModule = mod;
+  RGBAPaletteSubEditor::SetModel(fModule->GetPalette());
+  
+  fScale->SetIntNumber(ITSScaledModule::fgDigitScaleInfo->GetScale());
+  fStatistic->Select(ITSScaledModule::fgDigitScaleInfo->GetStatType(), kFALSE);
+  
+  Int_t cnx, cnz, total;
+  Float_t  maxoc;
+  GetSubDetScaleData(cnx, cnz, total, maxoc);
+  fInfoLabel0->SetText(Form("Cell size:  Nx=%d Nz=%d", cnx, cnz));
+  fInfoLabel1->SetText(Form("Num cells:  %d", total));
+  fInfoLabel2->SetText(Form("Max occupancy:  %5.3f%%", maxoc));
+
+  SetPaletteFromDigitInfo();
+}
+
+/**************************************************************************/
+
+void ITSSDSubEditor::GetSubDetScaleData(Int_t& cnx, Int_t& cnz, Int_t& total, Float_t& maxoc)
+{
+  Int_t scale = fScale->GetIntNumber() -1;
+  Alieve::ITSDigitsInfo* di = fModule->GetDigitsInfo();
+  switch(fModule->fDetID)
+  {
+    case 0: 
+      cnx =   di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale];
+      total =   di->fSegSPD->Npx()*di->fSegSPD->Npz();
+      maxoc = di->fSPDMaxOcc;;
+      break;
+    case 1:
+      cnx =   di->fSDDScaleX[scale], cnz = di->fSDDScaleZ[scale];
+      total = di->fSegSDD->Npx()*di->fSegSDD->Npz();
+      maxoc = di->fSDDMaxOcc;;
+      break;
+    case 2:
+      cnx =   di->fSSDScale[scale], cnz = 1;
+      total = di->fSegSSD->Npx()*di->fSegSSD->Npz();
+      maxoc = di->fSSDMaxOcc;;
+      break;
+  }
+}
+
+/**************************************************************************/
+
+void ITSSDSubEditor::SetPaletteFromDigitInfo()
+{  
+  // apply values for color palette
+  if(ITSScaledModule::fgDigitScaleInfo->fAutoUpdatePalette) 
+  {   
+    Int_t cnx, cnz, total;
+    Float_t  maxoc;
+    GetSubDetScaleData(cnx, cnz, total, maxoc);
+    Alieve::ITSDigitsInfo* di = fModule->GetDigitsInfo();
+    if(fStatistic->GetSelected() == DigitScaleInfo::ST_Occup) 
+    {
+      Int_t scale = fScale->GetIntNumber() -1;
+      fMinMax->SetValues(0, TMath::Max(Int_t(cnx*cnz*maxoc),1), kFALSE);
+      ITSModule::fgSPDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSPDScaleZ[scale]*di->fSPDScaleX[scale]*di->fSPDMaxOcc), 1));
+      ITSModule::fgSDDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSDDScaleZ[scale]*di->fSDDScaleX[scale]*di->fSPDMaxOcc), 1));
+      ITSModule::fgSSDPalette->SetMinMax(0,TMath::Max(Int_t(di->fSSDScale[scale]*di->fSPDMaxOcc), 1));
+    }
+    else 
+    {
+      ITSModule::fgSPDPalette->SetMinMax(di->fSPDMinVal,di->fSPDMaxVal);
+      ITSModule::fgSDDPalette->SetMinMax(di->fSDDMinVal,di->fSDDMaxVal);
+      ITSModule::fgSSDPalette->SetMinMax(di->fSSDMinVal,di->fSSDMaxVal);
+    }
+  }
+}
+
+/**************************************************************************/
+
+void ITSSDSubEditor::DoScale()
+{
+  Int_t cnx, cnz, total; Float_t  maxoc;
+  GetSubDetScaleData(cnx, cnz, total, maxoc);
+  fInfoLabel0->SetText(Form("Cell size:  Nx=%d Nz=%d", cnx, cnz));
+
+  SetPaletteFromDigitInfo();
+
+  ITSScaledModule::fgDigitScaleInfo->ScaleChanged(fScale->GetIntNumber());
+  Changed();
+}
+
+/**************************************************************************/
+
+void ITSSDSubEditor::DoStatType(Int_t v)
+{
+  // update palette
+  SetPaletteFromDigitInfo();
+
+  ITSScaledModule::fgDigitScaleInfo->StatTypeChanged(v);
+  
+  Changed(); 
+}
+
+//______________________________________________________________________
+// ITSScaledModuleEditor 
+//
+
+ClassImp(ITSScaledModuleEditor)
+
+ITSScaledModuleEditor::ITSScaledModuleEditor(const TGWindow *p, Int_t width, Int_t height,
+                                              UInt_t options, Pixel_t back) :
+    TGedFrame(p, width, height, options | kVerticalFrame, back),
+    fM(0), 
+    fHMTrans   (0),
+    fSDPalette   (0)
+{
+  MakeTitle("ITSScaledModule");
+  
+  fHMTrans = new ZTransSubEditor(this);
+  fHMTrans->Connect("UseTrans()",     "Alieve::ITSScaledModuleEditor", this, "Update()");
+  fHMTrans->Connect("TransChanged()", "Alieve::ITSScaledModuleEditor", this, "Update()");
+  AddFrame(fHMTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
+
+  MakeTitle("Palette controls");
+
+  fSDPalette = new ITSSDSubEditor(this);
+  fSDPalette->Connect("Changed", "Alieve::ITSScaledModuleEditor", this, "Update()");
+  AddFrame(fSDPalette, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 0, 0));
+}
+
+/*************************************************************************/
+ITSScaledModuleEditor::~ITSScaledModuleEditor()
+{}
+
+/**************************************************************************/
+
+void ITSScaledModuleEditor::ActivateBaseClassEditors(TClass* cl)
+{
+  // exclude QuadSet editor
+  fGedEditor->ExcludeClassEditor(QuadSet::Class());
+  TGedFrame::ActivateBaseClassEditors(cl);
+}
+
+/**************************************************************************/
+
+void ITSScaledModuleEditor::SetModel(TObject* obj)
+{
+  fM = dynamic_cast<ITSScaledModule*>(obj);
+
+  fHMTrans->SetDataFromTrans(&fM->RefHMTrans());
+
+  if (fM->GetValueIsColor() || fM->GetPalette() == 0) {
+    fSDPalette->UnmapWindow();
+  } else {
+    fSDPalette->SetModel(fM);
+    fSDPalette->MapWindow();
+  } 
+}
diff --git a/EVE/Alieve/ITSScaledModuleEditor.h b/EVE/Alieve/ITSScaledModuleEditor.h
new file mode 100644 (file)
index 0000000..8919a0a
--- /dev/null
@@ -0,0 +1,84 @@
+// $Header$
+
+#ifndef ALIEVE_ITSScaledModuleEditor_H
+#define ALIEVE_ITSScaledModuleEditor_H
+
+#include <TGedFrame.h>
+#include <Reve/RGBAPaletteEditor.h>
+
+class TGNumberEntry;
+class TGColorSelect;
+class TGComboBox;
+
+namespace Reve 
+{
+class RGValuator;
+class RGDoubleValuator;
+class RGBAPalette;
+class ZTransSubEditor;
+}
+
+namespace Alieve {
+
+class DigitScaleInfo;
+class ITSScaledModule;
+class AliITSsegmentation;
+
+class ITSSDSubEditor : public Reve::RGBAPaletteSubEditor
+{
+private:
+  ITSSDSubEditor(const ITSSDSubEditor&);            // Not implemented
+  ITSSDSubEditor& operator=(const ITSSDSubEditor&); // Not implemented
+  
+  void GetSubDetScaleData(Int_t& cnx, Int_t& cnz, Int_t& total, Float_t& maxoc);
+  void SetPaletteFromDigitInfo();
+protected:
+  ITSScaledModule*  fModule;
+
+  TGNumberEntry*    fScale;
+  TGComboBox*       fStatistic;  
+
+  TGLabel*          fInfoLabel0;
+  TGLabel*          fInfoLabel1;
+  TGLabel*          fInfoLabel2;
+
+public:
+  ITSSDSubEditor(const TGWindow* p);
+  virtual ~ITSSDSubEditor() {}
+
+  void SetModel(ITSScaledModule* sm);
+
+  void DoScale();
+  void DoStatType(Int_t t);
+
+  ClassDef(ITSSDSubEditor, 1); // SubEditor for RGBAPalelet and scaled digits
+};  // endclass ITSSDPaletteSubEditor
+
+/**************************************************************************/
+
+class ITSScaledModuleEditor : public TGedFrame
+{
+private:
+  ITSScaledModuleEditor(const ITSScaledModuleEditor&);            // Not implemented
+  ITSScaledModuleEditor& operator=(const ITSScaledModuleEditor&); // Not implemented
+
+protected:
+  ITSScaledModule*       fM; // fModel dynamic-casted to ITSScaledModuleEditor
+
+  Reve::ZTransSubEditor* fHMTrans;
+  ITSSDSubEditor*        fSDPalette;
+  
+public:
+  ITSScaledModuleEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30, UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+  virtual ~ITSScaledModuleEditor();
+
+  virtual void   ActivateBaseClassEditors(TClass* cl);
+
+  virtual void   SetModel(TObject* obj);
+
+  ClassDef(ITSScaledModuleEditor, 0); // Editor for ITSScaledModule
+}; // endclass ITSScaledModuleEditor
+
+}
+
+#endif