// $Id$ // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 /************************************************************************** * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * * full copyright notice. * **************************************************************************/ #include "AliEveITSModule.h" #include #include #include #include Bool_t AliEveITSModule::fgStaticInitDone = kFALSE; TEveFrameBox* AliEveITSModule::fgSPDFrameBox = 0; TEveFrameBox* AliEveITSModule::fgSDDFrameBox = 0; TEveFrameBox* AliEveITSModule::fgSSDFrameBox = 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) : TEveQuadSet(n, t), fInfo(0), fID(-1), fDetID(-1), fLayer(-1), fLadder(-1), fDet(-1), fDx(0), fDz(0), fDy(0) {} AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) : TEveQuadSet(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(gid); } AliEveITSModule::~AliEveITSModule() { if(fInfo) fInfo->DecRefCount(); } /******************************************************************************/ void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info) { if (fgStaticInitDone) return; fgStaticInitDone = kTRUE; { Float_t dx = info->fSegSPD->Dx()*0.00005; Float_t dz = 3.50; fgSPDFrameBox = new TEveFrameBox(); fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); fgSPDFrameBox->SetFrameColor((Color_t) 31); fgSPDFrameBox->SetFrameFill(kTRUE); fgSPDFrameBox->IncRefCount(); fgSPDPalette = new TEveRGBAPalette(info->fSPDMinVal,info->fSPDMaxVal); fgSPDPalette->IncRefCount(); } { Float_t dx = info->fSegSDD->Dx()*0.0001; Float_t dz = info->fSegSDD->Dz()*0.00005; fgSDDFrameBox = new TEveFrameBox(); fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); 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(); } { Float_t dx = info->fSegSSD->Dx()*0.00005; Float_t dz = info->fSegSSD->Dz()*0.00005; fgSSDFrameBox = new TEveFrameBox(); fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); 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(); } } /******************************************************************************/ void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info) { if (fInfo == info) return; if (fInfo) fInfo->DecRefCount(); fInfo = info; if (fInfo) fInfo->IncRefCount(); } /******************************************************************************/ void AliEveITSModule::SetID(Int_t gid, Bool_t trans) { static const TEveException eH("AliEveITSModule::SetID "); if(fInfo == 0) throw(eH + "AliEveITSDigitsInfo 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); TString strLadder = "Ladder"; TString strSensor = "Sensor"; TString symname; Int_t id, nsector, nstave, nladder, rest; if (fID <= fInfo->fGeom->GetLastSPD()) { // SPD SetFrame(fgSPDFrameBox); SetPalette(fgSPDPalette); symname += strLadder; if (fID < 80) { nsector = fID/8; rest = fID - 8*nsector; nstave = 1; } else { id = fID - 80; nsector = id/8; rest = id - 8*nsector; nstave = 1; } if (rest < 4) nstave = 0; 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()) { // SDD SetFrame(fgSDDFrameBox); SetPalette(fgSDDPalette); symname += strSensor; if (fID < 324) { id = fID - 240; nladder = id/6; rest = id - 6*nladder; } else { id = fID - 324; nladder = id/8; rest = id - 8*nladder; } 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); SetPalette(fgSSDPalette); symname += strSensor; if (fID < 1248) { id = fID - 500; nladder = id/22; rest = id - nladder*22; } else { id = fID - 1248; nladder = id/25; rest = id - nladder*25; } 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(); ComputeBBox(); 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"); TClonesArray *digits = fInfo->GetDigits(fID, fDetID); Int_t ndigits = digits ? digits->GetEntriesFast() : 0; Float_t x, z, dpx, dpz; Int_t i, j; switch(fDetID) { case 0: { // SPD AliITSsegmentationSPD* seg = fInfo->fSegSPD; Reset(kQT_RectangleXZFixedY, kFALSE, 32); for (Int_t k=0; kUncheckedAt(k); j = d->GetCoord1(); i = d->GetCoord2(); x = -0.5*seg->Dx() + i*seg->Dpx(0); x *= 0.0001; fInfo->GetSPDLocalZ(j, z); dpx = seg->Dpx(i)*0.0001; dpz = seg->Dpz(j)*0.0001; AddQuad(x, z, dpx, dpz); QuadValue(1); // In principle could have color based on number of neigbours QuadId(d); } break; } case 1: { // SDD AliITSsegmentationSDD *seg = fInfo->fSegSDD; Reset(kQT_RectangleXZFixedY, kFALSE, 32); for (Int_t k=0; kUncheckedAt(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); } } break; } case 2: { // SSD AliITSsegmentationSSD* seg = fInfo->fSegSSD; Reset(kQT_LineXZFixedY, kFALSE, 32); Float_t ap, an; // positive/negative angles -> offsets seg->Angles(ap, an); ap = TMath::Tan(ap) * fDz; an = - TMath::Tan(an) * fDz; for (Int_t k=0; kUncheckedAt(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); } } break; } } // end switch RefitPlex(); } /******************************************************************************/ 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); } /******************************************************************************/ void AliEveITSModule::DigitSelected(Int_t idx) { // Override control-click from TEveQuadSet DigitBase_t* qb = GetDigit(idx); TObject* obj = qb->fId.GetObject(); AliITSdigit* d = dynamic_cast(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); if (d) printf(" coord1=%3d coord2=%3d signal=%d\n", d->GetCoord1(), d->GetCoord2(), d->GetSignal()); } /******************************************************************************/ void AliEveITSModule::Print(Option_t* ) const { printf("ID %d, layer %d, ladder %d, det %d \n", fID, fLayer, fLadder, fDetID); }