]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveITSModule.cxx
Add dead module handling for SDD and SSD.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveITSModule.cxx
index d371b54b7a52f76fc110a8162638e195a26a11d1..e2b897b46e693a260555dff208372bea8a99dd29 100644 (file)
@@ -6,33 +6,42 @@
  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
  * full copyright notice.                                                 *
  **************************************************************************/
+
 #include "AliEveITSModule.h"
 
+#include <AliITSgeomTGeo.h>
+#include <AliITSsegmentationSPD.h>
+#include <AliITSsegmentationSDD.h>
+#include <AliITSsegmentationSSD.h>
+
 #include <AliITSdigitSPD.h>
 #include <AliITSdigitSDD.h>
 #include <AliITSdigitSSD.h>
 
+#include <TEveTrans.h>
+#include <TClonesArray.h>
 #include <TStyle.h>
 
 
+//______________________________________________________________________________
+//
+// Visualization of an ITS module.
 
-Bool_t       AliEveITSModule::fgStaticInitDone = kFALSE;
+ClassImp(AliEveITSModule)
 
-TEveFrameBox*    AliEveITSModule::fgSPDFrameBox = 0;
-TEveFrameBox*    AliEveITSModule::fgSDDFrameBox = 0;
-TEveFrameBox*    AliEveITSModule::fgSSDFrameBox = 0;
+Bool_t AliEveITSModule::fgStaticInitDone = kFALSE;
+
+TEveFrameBox*    AliEveITSModule::fgSPDFrameBox     = 0;
+TEveFrameBox*    AliEveITSModule::fgSPDFrameBoxDead = 0;
+TEveFrameBox*    AliEveITSModule::fgSDDFrameBox     = 0;
+TEveFrameBox*    AliEveITSModule::fgSDDFrameBoxDead = 0;
+TEveFrameBox*    AliEveITSModule::fgSSDFrameBox     = 0;
+TEveFrameBox*    AliEveITSModule::fgSSDFrameBoxDead = 0;
 
 TEveRGBAPalette* AliEveITSModule::fgSPDPalette  = 0;
 TEveRGBAPalette* AliEveITSModule::fgSDDPalette  = 0;
 TEveRGBAPalette* AliEveITSModule::fgSSDPalette  = 0;
 
-//______________________________________________________________________________
-// AliEveITSModule
-//
-//
-
-ClassImp(AliEveITSModule)
-
 /******************************************************************************/
 
 AliEveITSModule::AliEveITSModule(const Text_t* n, const Text_t* t) :
@@ -41,7 +50,9 @@ AliEveITSModule::AliEveITSModule(const Text_t* n, const Text_t* t) :
   fID(-1), fDetID(-1),
   fLayer(-1), fLadder(-1), fDet(-1),
   fDx(0), fDz(0), fDy(0)
-{}
+{
+  // Constructor.
+}
 
 AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) :
   TEveQuadSet(Form("ITS module %d", gid)),
@@ -50,33 +61,48 @@ AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) :
   fLayer(-1), fLadder(-1), fDet(-1),
   fDx(0), fDz(0), fDy(0)
 {
+  // Constructor with module id and data-source.
+
   SetDigitsInfo(info);
   SetID(gid);
 }
 
 AliEveITSModule::~AliEveITSModule()
 {
-  if(fInfo) fInfo->DecRefCount();
+  // Destructor.
+
+  if (fInfo) fInfo->DecRefCount();
 }
 
 /******************************************************************************/
 
 void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
 {
+  // Initialize static variables.
+  //
+  // Warning all sensor sizes are in microns, here we transform them
+  // to cm. In Eve half-lengths/widths are used, hence another 1/2.
+
   if (fgStaticInitDone) return;
   fgStaticInitDone = kTRUE;
 
   {
     Float_t dx = info->fSegSPD->Dx()*0.00005;
-    Float_t dz = 3.50;
+    Float_t dz = info->fSegSPD->Dz()*0.00005;
 
     fgSPDFrameBox = new TEveFrameBox();
     fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
-    fgSPDFrameBox->SetFrameColor((Color_t) 31);
+    fgSPDFrameBox->SetFrameColor(Color_t(31));
     fgSPDFrameBox->SetFrameFill(kTRUE);
     fgSPDFrameBox->IncRefCount();
     fgSPDPalette  = new TEveRGBAPalette(info->fSPDMinVal,info->fSPDMaxVal);
     fgSPDPalette->IncRefCount();
+
+    fgSPDFrameBoxDead = new TEveFrameBox();
+    fgSPDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
+    fgSPDFrameBoxDead->SetFrameColor(kRed);
+    fgSPDFrameBoxDead->SetFrameFill(kTRUE);
+    fgSPDFrameBoxDead->IncRefCount();
   }
 
   {
@@ -85,12 +111,18 @@ void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
 
     fgSDDFrameBox = new TEveFrameBox();
     fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
-    fgSDDFrameBox->SetFrameColor((Color_t) 32);
+    fgSDDFrameBox->SetFrameColor(Color_t(32));
     fgSDDFrameBox->SetFrameFill(kTRUE);
     fgSDDFrameBox->IncRefCount();
     fgSDDPalette  = new TEveRGBAPalette(info->fSDDMinVal,info->fSDDMaxVal);
     fgSDDPalette->SetLimits(0, info->fSDDHighLim); // Set proper ADC range.
     fgSDDPalette->IncRefCount();
+
+    fgSDDFrameBoxDead = new TEveFrameBox();
+    fgSDDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
+    fgSDDFrameBoxDead->SetFrameColor(kRed);
+    fgSDDFrameBoxDead->SetFrameFill(kTRUE);
+    fgSDDFrameBoxDead->IncRefCount();
   }
 
   {
@@ -99,12 +131,18 @@ void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
 
     fgSSDFrameBox = new TEveFrameBox();
     fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
-    fgSSDFrameBox->SetFrameColor((Color_t) 33);
+    fgSSDFrameBox->SetFrameColor(Color_t(33));
     fgSSDFrameBox->SetFrameFill(kTRUE);
     fgSSDFrameBox->IncRefCount();
     fgSSDPalette  = new TEveRGBAPalette(info->fSSDMinVal,info->fSSDMaxVal);
     fgSSDPalette->SetLimits(0, info->fSSDHighLim); // Set proper ADC range.
     fgSSDPalette->IncRefCount();
+
+    fgSSDFrameBoxDead = new TEveFrameBox();
+    fgSSDFrameBoxDead->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz);
+    fgSSDFrameBoxDead->SetFrameColor(kRed);
+    fgSSDFrameBoxDead->SetFrameFill(kTRUE);
+    fgSSDFrameBoxDead->IncRefCount();
   }
 
 }
@@ -113,6 +151,8 @@ void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info)
 
 void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info)
 {
+  // Set data and geometry source.
+
   if (fInfo == info) return;
   if (fInfo) fInfo->DecRefCount();
   fInfo = info;
@@ -123,41 +163,41 @@ void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info)
 
 void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
 {
-  static const TEveException eH("AliEveITSModule::SetID ");
+  // Set detector id.
 
-  if(fInfo == 0)
-    throw(eH + "AliEveITSDigitsInfo not set.");
+  static const TEveException kEH("AliEveITSModule::SetID ");
 
-  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()));
+  if (fInfo == 0)
+    throw(kEH + "AliEveITSDigitsInfo not set.");
+
+  Int_t firstSPD = AliITSgeomTGeo::GetModuleIndex(1,1,1);
+  Int_t lastSSD  = AliITSgeomTGeo::GetNModules() - 1;
+  if (gid < firstSPD || gid > lastSSD)
+  {
+    throw(kEH + Form("%d is not valid. ID range from %d to %d", gid,
+                   firstSPD, lastSSD ));
+  }
 
   fID = gid;
 
-  if (!fgStaticInitDone) {
+  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);
+  AliITSgeomTGeo::GetModuleId(fID, fLayer, fLadder, fDet);
   TString strLadder = "Ladder";
   TString strSensor = "Sensor";
   TString symname;
   Int_t   id, nsector, nstave, nladder, rest;
 
-  if (fID <= fInfo->fGeom->GetLastSPD())
+  if (fID <= (AliITSgeomTGeo::GetModuleIndex(3,1,1) - 1))
   {
     // SPD
 
-    SetFrame(fgSPDFrameBox);
+    fDetID = 0;
+
+    SetFrame(fInfo->IsDead(fID, fDetID) ? fgSPDFrameBoxDead : fgSPDFrameBox);
     SetPalette(fgSPDPalette);
 
     symname += strLadder;
@@ -178,17 +218,17 @@ void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
     rest    -= 4*nstave;
     symname += rest;
     SetName(symname);
-    fDetID = 0;
     fDx = fInfo->fSegSPD->Dx()*0.00005;
     fDz = 3.50;
     fDy = fInfo->fSegSPD->Dy()*0.00005;
-
   }
-  else if (fID <= fInfo->fGeom->GetLastSDD())
+  else if (fID <= (AliITSgeomTGeo::GetModuleIndex(5,1,1) - 1))
   {
     // SDD
 
-    SetFrame(fgSDDFrameBox);
+    fDetID = 1;
+
+    SetFrame(fInfo->IsDead(fID, fDetID) ? fgSDDFrameBoxDead : fgSDDFrameBox);
     SetPalette(fgSDDPalette);
 
     symname += strSensor;
@@ -206,17 +246,17 @@ void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
     }
     symname += rest;
     SetName(symname);
-    fDetID = 1;
     fDx = fInfo->fSegSDD->Dx()*0.0001;
     fDz = fInfo->fSegSDD->Dz()*0.00005;
     fDy = fInfo->fSegSDD->Dy()*0.00005;
-
   }
   else
   {
     // SSD
 
-    SetFrame(fgSSDFrameBox);
+    fDetID = 2;
+
+    SetFrame(fInfo->IsDead(fID, fDetID) ? fgSSDFrameBoxDead : fgSSDFrameBox);
     SetPalette(fgSSDPalette);
 
     symname += strSensor;
@@ -234,28 +274,25 @@ void AliEveITSModule::SetID(Int_t gid, Bool_t trans)
     }
     symname += rest;
     SetName(symname);
-    fDetID = 2;
     fInfo->fSegSSD->SetLayer(fLayer);
     fDx = fInfo->fSegSSD->Dx()*0.00005;
     fDz = fInfo->fSegSSD->Dz()*0.00005;
     fDy = fInfo->fSegSSD->Dy()*0.00005;
-
   }
 
   LoadQuads();
+  RefitPlex();
   ComputeBBox();
+  InitMainTrans();
   if (trans)
     SetTrans();
+
 }
 
 void AliEveITSModule::LoadQuads()
 {
-  // Here we still use 'z' for the name of axial coordinates.
-  // The transforamtion matrix aplied rotates y -> z.
-  // We need this as TEveQuadSet offers optimized treatment for
-  // quads in the x-y plane.
-
-  // printf("its module load quads \n");
+  // Read module data from source and create low-level objects for
+  // visualization - called quads.
 
   TClonesArray *digits  = fInfo->GetDigits(fID, fDetID);
   Int_t         ndigits = digits ? digits->GetEntriesFast() : 0;
@@ -265,8 +302,8 @@ void AliEveITSModule::LoadQuads()
 
   switch(fDetID)
   {
-
-    case 0: { // SPD
+    case 0:
+    {
       AliITSsegmentationSPD* seg =  fInfo->fSegSPD;
 
       Reset(kQT_RectangleXZFixedY, kFALSE, 32);
@@ -289,7 +326,8 @@ void AliEveITSModule::LoadQuads()
       break;
     }
 
-    case 1: { // SDD
+    case 1:
+    {
       AliITSsegmentationSDD *seg =  fInfo->fSegSDD;
 
       Reset(kQT_RectangleXZFixedY, kFALSE, 32);
@@ -298,23 +336,21 @@ void AliEveITSModule::LoadQuads()
       {
        AliITSdigit* d = (AliITSdigit*) digits->UncheckedAt(k);
 
-       // if (d->GetSignal() > fgSDDThreshold)
-       {
-         j = d->GetCoord1();
-         i = d->GetCoord2();
-         seg->DetToLocal(i, j, x, z);
-         dpx = seg->Dpx(i)*0.0001;
-         dpz = seg->Dpz(j)*0.0001;
-
-         AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz);
-         QuadValue(d->GetSignal());
-         QuadId(d);
-       }
+       j = d->GetCoord1();
+       i = d->GetCoord2();
+       seg->DetToLocal(i, j, x, z);
+       dpx = seg->Dpx(i)*0.0001;
+       dpz = seg->Dpz(j)*0.0001;
+
+       AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz);
+       QuadValue(d->GetSignal());
+       QuadId(d);
       }
       break;
     }
 
-    case 2: { // SSD
+    case 2:
+    {
       AliITSsegmentationSSD* seg = fInfo->fSegSSD;
 
       Reset(kQT_LineXZFixedY, kFALSE, 32);
@@ -327,26 +363,24 @@ void AliEveITSModule::LoadQuads()
       for (Int_t k=0; k<ndigits; ++k)
       {
        AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k);
-       // if(d->GetSignal() > fgSSDThreshold)
-       {
-         j = d->GetCoord1();
-         i = d->GetCoord2();
-         seg->DetToLocal(i,j,x,z);
-
-         Float_t a = ( d->GetCoord1() == 1) ? ap : an;
-
-         AddLine(x-a, -fDz, 2*a, 2*fDz);
-         QuadValue(d->GetSignal());
-         QuadId(d);
-         // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color);
-       }
+
+       j = d->GetCoord1();
+       i = d->GetCoord2();
+       // !!!! The following function complains about not being verified.
+       // !!!! Experts should check.
+       seg->DetToLocal(i,j,x,z);
+
+       Float_t a = (d->GetCoord1() == 1) ? ap : an;
+
+       AddLine(x-a, -fDz, 2*a, 2*fDz);
+       QuadValue(d->GetSignal());
+       QuadId(d);
+       // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color);
       }
       break;
     }
 
   } // end switch
-
-  RefitPlex();
 }
 
 /******************************************************************************/
@@ -356,31 +390,18 @@ void AliEveITSModule::SetTrans()
   // Set transformation matrix based on module id (use geometry to
   // retrieve this information).
 
-  Double_t x[9];
-  fHMTrans.UnitTrans();
-
-  // !!!! 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]);
-  fHMTrans.SetBaseVec(3, x[2], x[5], x[8]);
-  // translation
-  fInfo->fGeom->GetTrans(fID, x);
-  fHMTrans.SetBaseVec(4, x);
+  fMainTrans->SetFrom(*AliITSgeomTGeo::GetMatrix(fID));
 }
 
 /******************************************************************************/
 
 void AliEveITSModule::DigitSelected(Int_t idx)
 {
-  // Override control-click from TEveQuadSet
+  // Override secondary select (alt-click) from TEveQuadSet.
 
-  DigitBase_t* qb   = GetDigit(idx);
-  TObject* obj   = qb->fId.GetObject();
-  AliITSdigit* d = dynamic_cast<AliITSdigit*>(obj);
+  DigitBase_t *qb  = GetDigit(idx);
+  TObject     *obj = qb->fId.GetObject();
+  AliITSdigit *d   = dynamic_cast<AliITSdigit*>(obj);
   printf("AliEveITSModule::QuadSelected "); Print();
   printf("  idx=%d, value=%d, obj=0x%lx, digit=0x%lx\n",
         idx, qb->fValue, (ULong_t)obj, (ULong_t)d);
@@ -394,5 +415,8 @@ void AliEveITSModule::DigitSelected(Int_t idx)
 
 void AliEveITSModule::Print(Option_t* ) const
 {
-  printf("ID %d, layer %d, ladder %d, det %d \n", fID, fLayer, fLadder, fDetID);
+  // Print object summary information.
+
+  printf("AliEveITSModule: ID %d, layer %d, ladder %d, det %d\n",
+         fID, fLayer, fLadder, fDetID);
 }