]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/Alieve/ITSModule.cxx
Moved from Reve to Alieve.
[u/mrichter/AliRoot.git] / EVE / Alieve / ITSModule.cxx
index b81c95791a774cecfe2cb4eab0f5c8fb90370efa..d3c46fb9230bf6b82edd02e2c66fd4e2b851cb5b 100644 (file)
@@ -9,12 +9,6 @@
 using namespace Reve;
 using namespace Alieve;
 
-/*
-Short_t ITSModule::fgSDDThreshold  = 5;
-Short_t ITSModule::fgSDDMaxVal     = 80;
-Short_t ITSModule::fgSSDThreshold  = 2;
-Short_t ITSModule::fgSSDMaxVal     = 100;
-*/
 
 Bool_t       ITSModule::fgStaticInitDone = kFALSE;
 
@@ -43,15 +37,15 @@ ITSModule::ITSModule(const Text_t* n, const Text_t* t) :
   fDx(0), fDz(0), fDy(0)
 {}
 
-ITSModule::ITSModule(Int_t id, ITSDigitsInfo* info) :
-  QuadSet(Form("ITS module %d", id)),
+ITSModule::ITSModule(Int_t gid, ITSDigitsInfo* info) :
+  QuadSet(Form("ITS module %d", gid)),
   fInfo  (0),
   fID(-1), fDetID(-1),
   fLayer(-1), fLadder(-1), fDet(-1),
   fDx(0), fDz(0), fDy(0)
 {
   SetDigitsInfo(info);
-  SetID(id);
+  SetID(gid);
 }
 
 ITSModule::~ITSModule()
@@ -61,42 +55,22 @@ ITSModule::~ITSModule()
 
 /**************************************************************************/
 
-void ITSModule::SetDigitsInfo(ITSDigitsInfo* info)
-{
-  if(fInfo) fInfo->DecRefCount();
-  fInfo = info;
-  if(fInfo) fInfo->IncRefCount();
-}
-
-void ITSModule::SetID(Int_t id)
-{
-  static const Exc_t eH("ITSModule::SetID ");
-
-  if(fInfo == 0)
-    throw(eH + "ITSDigitsInfo not set.");
-
-  if (id < fInfo->fGeom->GetStartSPD() || id > fInfo->fGeom->GetLastSSD())
-    throw(eH + Form("%d is not valid. ID range from %d to %d", id,
-                    fInfo->fGeom->GetStartSPD(), fInfo->fGeom->GetLastSSD()));
-
-  fID = id;
-  InitModule();
-}
-
-/**************************************************************************/
-
 void ITSModule::InitStatics(ITSDigitsInfo* info)
 {
   if (fgStaticInitDone) return;
+  fgStaticInitDone = kTRUE;
 
   {
     Float_t dx = info->fSegSPD->Dx()*0.00005;
-    Float_t dz = 3.48
+    Float_t dz = 3.50
 
     fgSPDFrameBox = new FrameBox();
     fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
     fgSPDFrameBox->SetFrameColor((Color_t) 31);
-    fgSPDPalette  = new RGBAPalette(0, 1, kFALSE, kFALSE);
+    fgSPDFrameBox->SetFrameFill(kTRUE);
+    fgSPDFrameBox->IncRefCount();
+    fgSPDPalette  = new RGBAPalette(info->fSPDMinVal,info->fSPDMaxVal);
+    fgSPDPalette->IncRefCount();
   }
 
   {
@@ -106,7 +80,11 @@ void ITSModule::InitStatics(ITSDigitsInfo* info)
     fgSDDFrameBox = new FrameBox();
     fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
     fgSDDFrameBox->SetFrameColor((Color_t) 32);
-    fgSDDPalette  = new RGBAPalette(5, 80, kTRUE, kFALSE);
+    fgSDDFrameBox->SetFrameFill(kTRUE);
+    fgSDDFrameBox->IncRefCount();
+    fgSDDPalette  = new RGBAPalette(info->fSDDMinVal,info->fSDDMaxVal);
+    fgSDDPalette->SetLimits(0, info->fSDDHighLim); // Set proper ADC range.
+    fgSDDPalette->IncRefCount();
   }
 
   {
@@ -116,27 +94,66 @@ void ITSModule::InitStatics(ITSDigitsInfo* info)
     fgSSDFrameBox = new FrameBox();
     fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
     fgSSDFrameBox->SetFrameColor((Color_t) 33);
-    fgSSDPalette  = new RGBAPalette(2, 100, kTRUE, kFALSE);
+    fgSSDFrameBox->SetFrameFill(kTRUE);
+    fgSSDFrameBox->IncRefCount();
+    fgSSDPalette  = new RGBAPalette(info->fSSDMinVal,info->fSSDMaxVal);
+    fgSSDPalette->SetLimits(0, info->fSSDHighLim); // Set proper ADC range.
+    fgSSDPalette->IncRefCount();
   }
 
 }
 
 /**************************************************************************/
 
-void ITSModule::InitModule()
+void ITSModule::SetDigitsInfo(ITSDigitsInfo* info)
+{
+  if (fInfo == info) return;
+  if (fInfo) fInfo->DecRefCount();
+  fInfo = info;
+  if (fInfo) fInfo->IncRefCount();
+}
+
+/**************************************************************************/
+
+void ITSModule::SetID(Int_t gid, Bool_t trans)
 {
-  if (!fgStaticInitDone)  InitStatics(fInfo);
+  static const Exc_t eH("ITSModule::SetID ");
+
+  if(fInfo == 0)
+    throw(eH + "ITSDigitsInfo not set.");
+
+  if (gid < fInfo->fGeom->GetStartSPD() || gid > fInfo->fGeom->GetLastSSD())
+    throw(eH + Form("%d is not valid. ID range from %d to %d", gid,
+                   fInfo->fGeom->GetStartSPD(), fInfo->fGeom->GetLastSSD()));
+
+  fID = gid;
+
+  if (!fgStaticInitDone) {
+    InitStatics(fInfo);
+    
+    fgSPDFrameBox->IncRefCount(this);
+    fgSPDPalette->IncRefCount();
+  
+    fgSDDFrameBox->IncRefCount(this);
+    fgSDDPalette->IncRefCount();
+
+    fgSSDFrameBox->IncRefCount(this);
+    fgSSDPalette->IncRefCount();
+  }
 
-  fInfo->fGeom->GetModuleId(fID,fLayer,fLadder,fDet);
+  fInfo->fGeom->GetModuleId(fID, fLayer, fLadder, fDet);
   TString strLadder = "Ladder";
   TString strSensor = "Sensor";
   TString symname;
-  Int_t id, nsector, nstave, nladder, rest;
+  Int_t   id, nsector, nstave, nladder, rest;
   
   if (fID <= fInfo->fGeom->GetLastSPD())
   {
     // SPD
 
+    SetFrame(fgSPDFrameBox);
+    SetPalette(fgSPDPalette);
     symname += strLadder;
     if (fID < 80)
     {
@@ -157,7 +174,7 @@ void ITSModule::InitModule()
     SetName(symname);
     fDetID = 0;
     fDx = fInfo->fSegSPD->Dx()*0.00005;
-    fDz = 3.48
+    fDz = 3.50
     fDy = fInfo->fSegSPD->Dy()*0.00005;
 
   }
@@ -165,6 +182,9 @@ void ITSModule::InitModule()
   {
     // SDD
 
+    SetFrame(fgSDDFrameBox);
+    SetPalette(fgSDDPalette);
     symname += strSensor;
     if (fID < 324)
     {
@@ -190,6 +210,9 @@ void ITSModule::InitModule()
   {
     // SSD
 
+    SetFrame(fgSSDFrameBox);
+    SetPalette(fgSSDPalette);
+
     symname += strSensor;
     if (fID < 1248)
     {
@@ -215,7 +238,8 @@ void ITSModule::InitModule()
 
   LoadQuads();  
   ComputeBBox();
-  SetTrans();
+  if (trans)
+    SetTrans();
 }
 
 void ITSModule::LoadQuads()
@@ -227,11 +251,11 @@ void ITSModule::LoadQuads()
 
   // printf("its module load quads \n");
 
-  TClonesArray *digits;
+  TClonesArray *digits  = fInfo->GetDigits(fID, fDetID);
+  Int_t         ndigits = digits ? digits->GetEntriesFast() : 0;
+
   Float_t       x, z, dpx, dpz; 
-  Int_t         i, j, ndigits;
-  digits  = fInfo->GetDigits(fID, fDetID);
-  ndigits = digits->GetEntriesFast(); 
+  Int_t         i, j;
 
   switch(fDetID)
   {
@@ -239,13 +263,11 @@ void ITSModule::LoadQuads()
     case 0: { // SPD
       AliITSsegmentationSPD* seg =  fInfo->fSegSPD; 
 
-      Reset(QT_AxisAlignedFixedY, kFALSE, 32);
-      fFrame   = fgSPDFrameBox;
-      fPalette = fgSPDPalette;
+      Reset(QT_RectangleXZFixedY, kFALSE, 32);
 
       for (Int_t k=0; k<ndigits; ++k)
       {
-       AliITSdigitSPD *d = (AliITSdigitSPD*) digits->UncheckedAt(k);
+       AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
        j = d->GetCoord1();
        i = d->GetCoord2();
        x  = -0.5*seg->Dx() + i*seg->Dpx(0);
@@ -256,6 +278,7 @@ void ITSModule::LoadQuads()
 
        AddQuad(x, z, dpx, dpz);
        QuadValue(1); // In principle could have color based on number of neigbours
+       QuadId(d);
       }
       break;
     }
@@ -263,13 +286,11 @@ void ITSModule::LoadQuads()
     case 1: { // SDD
       AliITSsegmentationSDD *seg =  fInfo->fSegSDD; 
 
-      Reset(QT_AxisAlignedFixedY, kFALSE, 32);
-      fFrame   = fgSDDFrameBox;
-      fPalette = fgSDDPalette;
+      Reset(QT_RectangleXZFixedY, kFALSE, 32);
 
       for (Int_t k=0; k<ndigits; ++k)
       {
-       AliITSdigitSDD* d = (AliITSdigitSDD*) digits->UncheckedAt(k);
+       AliITSdigit* d = (AliITSdigit*) digits->UncheckedAt(k);
 
        // if (d->GetSignal() > fgSDDThreshold)
        {
@@ -279,8 +300,9 @@ void ITSModule::LoadQuads()
          dpx = seg->Dpx(i)*0.0001;
          dpz = seg->Dpz(j)*0.0001;
 
-         AddQuad(x, z, dpx, dpz);
+         AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz);
          QuadValue(d->GetSignal());
+         QuadId(d);
        }
       }
       break;
@@ -289,9 +311,7 @@ void ITSModule::LoadQuads()
     case 2: { // SSD
       AliITSsegmentationSSD* seg = fInfo->fSegSSD; 
 
-      Reset(QT_LineFixedY, kFALSE, 32);
-      fFrame   = fgSSDFrameBox;
-      fPalette = fgSSDPalette;
+      Reset(QT_LineXZFixedY, kFALSE, 32);
 
       Float_t ap, an; // positive/negative angles -> offsets
       seg->Angles(ap, an);
@@ -300,7 +320,7 @@ void ITSModule::LoadQuads()
 
       for (Int_t k=0; k<ndigits; ++k)
       {
-       AliITSdigitSSD *d = (AliITSdigitSSD*) digits->UncheckedAt(k);
+       AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
        // if(d->GetSignal() > fgSSDThreshold)
        {
          j = d->GetCoord1();
@@ -309,8 +329,9 @@ void ITSModule::LoadQuads()
 
          Float_t a = ( d->GetCoord1() == 1) ? ap : an;
 
-         AddQuad(x-a, -fDz, 2*a, 2*fDz);
+         AddLine(x-a, -fDz, 2*a, 2*fDz);
          QuadValue(d->GetSignal());
+         QuadId(d);
          // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color);
        }
       }
@@ -326,10 +347,16 @@ void ITSModule::LoadQuads()
 
 void ITSModule::SetTrans()
 {
+  // Set transformation matrix based on module id (use geometry to
+  // retrieve this information).
+
   Double_t x[9];
   fHMTrans.UnitTrans();
 
-   // column major
+  // !!!! Here should use AliITSgeomTGeo ... but can i be sure
+  // the geometry has been loaded?
+
+  // column major
   fInfo->fGeom->GetRotMatrix(fID, x);
   fHMTrans.SetBaseVec(1, x[0], x[3], x[6]);
   fHMTrans.SetBaseVec(2, x[1], x[4], x[7]);
@@ -341,6 +368,24 @@ void ITSModule::SetTrans()
 
 /**************************************************************************/
 
+void ITSModule::DigitSelected(Int_t idx)
+{
+  // Override control-click from QuadSet
+
+  DigitBase* qb   = GetDigit(idx);
+  TObject* obj   = qb->fId.GetObject();
+  AliITSdigit* d = dynamic_cast<AliITSdigit*>(obj);
+  printf("ITSModule::QuadSelected "); Print();
+  printf("  idx=%d, value=%d, obj=0x%lx, digit=0x%lx\n",
+        idx, qb->fValue, (ULong_t)obj, (ULong_t)d);
+  if (d)
+    printf("  coord1=%3d coord2=%3d signal=%d\n",
+          d->GetCoord1(), d->GetCoord2(), d->GetSignal());
+
+}
+
+/**************************************************************************/
+
 void ITSModule::Print(Option_t* ) const
 {
   printf("ID %d, layer %d, ladder %d, det %d \n", fID, fLayer, fLadder, fDetID);