#include "TEveCalo.h"
#include "TEveCaloData.h"
#include "TEveProjections.h"
#include "TEveProjectionManager.h"
#include "TEveRGBAPalette.h"
#include "TEveText.h"
#include "TClass.h"
#include "TMathBase.h"
#include "TMath.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TVirtualPad.h"
#include "TVirtualViewer3D.h"
#include "TGLUtil.h"
ClassImp(TEveCaloViz);
TEveCaloViz::TEveCaloViz(const Text_t* n, const Text_t* t) :
TEveElement(),
TNamed(n, t),
TEveProjectable(),
fData(0),
fEtaLowLimit(-5.f),
fEtaHighLimit(5.f),
fEtaMin(fEtaLowLimit),
fEtaMax(fEtaHighLimit),
fPhi(0.),
fPhiRng(TMath::Pi()),
fBarrelRadius(-1.f),
fEndCapPos(-1.f),
fCellZScale(1.),
fValueIsColor(kTRUE),
fPalette(0),
fCacheOK(kFALSE)
{
SetElementName("TEveCaloViz");
}
TEveCaloViz::TEveCaloViz(TEveCaloData* data, const Text_t* n, const Text_t* t) :
TEveElement(),
TNamed(n, t),
fData(0),
fEtaLowLimit(-5.f),
fEtaHighLimit(5.f),
fEtaMin(fEtaLowLimit),
fEtaMax(fEtaHighLimit),
fPhi(0.),
fPhiRng(TMath::Pi()),
fBarrelRadius(-1.f),
fEndCapPos(-1.f),
fCellZScale(1.),
fValueIsColor(kTRUE),
fPalette(0),
fCacheOK(kFALSE)
{
SetData(data);
}
TEveCaloViz::~TEveCaloViz()
{
if (fPalette) fPalette->DecRefCount();
if (fData) fData->DecRefCount();
}
Float_t TEveCaloViz::GetTransitionTheta() const
{
return TMath::ATan(fBarrelRadius/fEndCapPos);
}
Float_t TEveCaloViz::GetTransitionEta() const
{
using namespace TMath;
Float_t t = GetTransitionTheta()*0.5f;
return -Log(Tan(t));
}
void TEveCaloViz::SetData(TEveCaloData* data)
{
if (data == fData) return;
if (fData) fData->DecRefCount();
fData = data;
if (fData) fData->IncRefCount();
InvalidateCache();
}
void TEveCaloViz::AssignCaloVizParameters(TEveCaloViz* m)
{
SetData(m->fData);
fEtaMin = m->fEtaMin;
fEtaMax = m->fEtaMax;
fEtaLowLimit = m->fEtaLowLimit;
fEtaHighLimit = m->fEtaHighLimit;
fPhi = m->fPhi;
fPhiRng = m->fPhiRng;
fBarrelRadius = m->fBarrelRadius;
fEndCapPos = m->fEndCapPos;
TEveRGBAPalette& mp = * m->fPalette;
TEveRGBAPalette* p = new TEveRGBAPalette(mp.GetMinVal(), mp.GetMaxVal(),
mp.GetInterpolate());
p->SetDefaultColor(mp.GetDefaultColor());
SetPalette(p);
}
void TEveCaloViz::SetPalette(TEveRGBAPalette* p)
{
if ( fPalette == p) return;
if (fPalette) fPalette->DecRefCount();
fPalette = p;
if (fPalette) fPalette->IncRefCount();
}
TEveRGBAPalette* TEveCaloViz::AssertPalette()
{
if (fPalette == 0) {
fPalette = new TEveRGBAPalette;
}
return fPalette;
}
void TEveCaloViz::Paint(Option_t* )
{
static const TEveException eH("TEvecaloViz::Paint ");
if (!fData)
return;
TBuffer3D buff(TBuffer3DTypes::kGeneric);
buff.fID = this;
buff.fTransparency = 0;
if (HasMainTrans())
RefMainTrans().SetBuffer3D(buff);
buff.SetSectionsValid(TBuffer3D::kCore);
Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
if (reqSections != TBuffer3D::kNone)
Error(eH, "only direct GL rendering supported.");
}
TClass* TEveCaloViz::ProjectedClass() const
{
return TEveCalo2D::Class();
}
void TEveCaloViz::SetupColorHeight(Float_t value, Int_t slice,
Float_t &outH, Bool_t &viz) const
{
Int_t val = (Int_t) value;
outH = GetDefaultCellHeight();
Bool_t visible = kFALSE;
if (fPalette->GetShowDefValue())
{
if (value > fPalette->GetMinVal() && value < fPalette->GetMaxVal())
{
TGLUtil::Color(fPalette->GetDefaultColor() + slice);
outH *= ((value -fPalette->GetMinVal())*fData->GetNSlices()
/ (fPalette->GetHighLimit() - fPalette->GetLowLimit()));
visible = kTRUE;
}
}
if (fPalette->GetShowDefValue() == kFALSE && fPalette->WithinVisibleRange(val))
{
UChar_t c[4];
fPalette->ColorFromValue(val, c);
TGLUtil::Color4ubv(c);
visible = kTRUE;
}
viz = visible;
}
ClassImp(TEveCalo3D);
void TEveCalo3D::ResetCache()
{
fCellList.clear();
}
void TEveCalo3D::ComputeBBox()
{
BBoxInit();
Float_t th = GetDefaultCellHeight()*fData->GetNSlices();
fBBox[0] = -fBarrelRadius - th;
fBBox[1] = fBarrelRadius + th;
fBBox[2] = fBBox[0];
fBBox[3] = fBBox[1];
fBBox[4] = -fEndCapPos - th;
fBBox[5] = fEndCapPos + th;
}
ClassImp(TEveCalo2D);
TEveCalo2D::TEveCalo2D(const Text_t* n, const Text_t* t):
TEveCaloViz(n, t),
TEveProjected(),
fOldProjectionType(TEveProjection::kPT_Unknown)
{
}
void TEveCalo2D::UpdateProjection()
{
if (fManager->GetProjection()->GetType() != fOldProjectionType)
{
fCacheOK=kFALSE;
fOldProjectionType = fManager->GetProjection()->GetType();
}
ComputeBBox();
}
void TEveCalo2D::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
{
TEveProjected::SetProjection(mng, model);
TEveCaloViz* viz = dynamic_cast<TEveCaloViz*>(model);
AssignCaloVizParameters(viz);
}
void TEveCalo2D::ResetCache()
{
for (std::vector<TEveCaloData::vCellId_t*>::iterator it = fCellLists.begin(); it != fCellLists.end(); it++)
{
delete *it;
}
fCellLists.clear();
}
void TEveCalo2D::ComputeBBox()
{
BBoxZero();
Float_t x, y, z;
Float_t th = GetDefaultCellHeight()*fData->GetNSlices();
Float_t r = fBarrelRadius + th;
Float_t ze = fEndCapPos + th;
x = r, y = 0, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
x = 0, y = 0, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
x = 0, y = 0, z = ze;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
x = 0, y = 0, z = -ze;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
x = 0, y = r, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
x = 0, y = -r, z = 0;
fManager->GetProjection()->ProjectPoint(x, y, z);
BBoxCheckPoint(x, y, z);
AssertBBoxExtents(0.1);
}
ClassImp(TEveCaloLego);
TEveCaloLego::TEveCaloLego(const Text_t* n, const Text_t* t):
TEveCaloViz(n, t),
fFontColor(0),
fGridColor(kGray+3),
fFontSize(10),
fNZStep(5),
fBinWidth(5),
fProjection(kAuto),
f2DMode(kValColor)
{
SetElementNameTitle("TEveCaloLego", "TEveCaloLego");
fCellZScale =0.5;
}
TEveCaloLego::TEveCaloLego(TEveCaloData* data):
TEveCaloViz(data),
fFontColor(0),
fGridColor(kGray+3),
fFontSize(10),
fNZStep(5),
fBinWidth(5),
fProjection(kAuto),
f2DMode(kValColor),
fBoxMode(kBack)
{
SetElementNameTitle("TEveCaloLego", "TEveCaloLego");
fCellZScale = 0.5;
}
Float_t TEveCaloLego::GetDefaultCellHeight() const
{
return TMath::TwoPi();
}
void TEveCaloLego::ResetCache()
{
fCellList.clear();
}
void TEveCaloLego::ComputeBBox()
{
BBoxInit();
fBBox[0] = 1.2f*fEtaMin;
fBBox[1] = 1.2f*fEtaMax;
fBBox[2] = fPhi - 1.2f*fPhiRng;
fBBox[3] = fPhi + 1.2f*fPhiRng;
fBBox[4] = -GetDefaultCellHeight()*fCellZScale*0.2;
fBBox[5] = GetDefaultCellHeight()*fCellZScale*1.2;
}
Last change: Tue May 13 17:08:27 2008
Last generated: 2008-05-13 17:08
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.