From 3a6f8a5061f64066aae5a9eaea90dd4753d5134c Mon Sep 17 00:00:00 2001 From: Matevz Tadel <matevz.tadel@cern.ch> Date: Fri, 30 May 2008 16:43:01 +0000 Subject: [PATCH] From Alja: - TEveCalo, TEveCaloLegoGL, TEveCalo2DGL, TEveCaloVizEditor: Add possibility to auto scale calorimeters. In class TEveCaloViz rename member fPhiRng to fPhiOffset. - cms_calo.C: Demonstrate auto scale and eta/phi range. git-svn-id: http://root.cern.ch/svn/root/trunk@24076 27541ba8-7e3a-0410-8455-c3a389f83636 --- graf3d/eve/inc/TEveCalo.h | 25 ++++-- graf3d/eve/inc/TEveCaloVizEditor.h | 2 +- graf3d/eve/src/TEveCalo.cxx | 54 ++++++++---- graf3d/eve/src/TEveCalo2DGL.cxx | 2 +- graf3d/eve/src/TEveCaloLegoGL.cxx | 121 ++++++++++++++++----------- graf3d/eve/src/TEveCaloVizEditor.cxx | 20 ++--- tutorials/eve/cms_calo.C | 40 ++++----- 7 files changed, 159 insertions(+), 105 deletions(-) diff --git a/graf3d/eve/inc/TEveCalo.h b/graf3d/eve/inc/TEveCalo.h index 3bbd835a1f5..6379b5c71d7 100644 --- a/graf3d/eve/inc/TEveCalo.h +++ b/graf3d/eve/inc/TEveCalo.h @@ -42,12 +42,15 @@ protected: Double_t fEtaMax; Double_t fPhi; - Double_t fPhiRng; + Double_t fPhiOffset; - Float_t fBarrelRadius; // barrel raidus in cm - Float_t fEndCapPos; // end cap z coordinate in cm + Float_t fBarrelRadius; // barrel raidus in cm + Float_t fEndCapPos; // end cap z coordinate in cm - Float_t fCellZScale; + Float_t fCellZScale; + + Bool_t fUseExternalZMax; + Float_t fExternalZMax; Bool_t fValueIsColor; // Interpret signal value as RGBA color. TEveRGBAPalette* fPalette; // Pointer to signal-color palette. @@ -77,6 +80,12 @@ public: virtual void SetCellZScale(Float_t s) { fCellZScale = s; ResetBBox(); } virtual Float_t GetDefaultCellHeight() const { return fBarrelRadius*fCellZScale; } + void SetUseExternalZMax(Bool_t x) { fUseExternalZMax = x; } + Bool_t GetUseExternalZMax() const { return fUseExternalZMax; } + + void SetExternalZMax(Float_t val) { fExternalZMax = val; } + Float_t GetExternalZMax() const { return fExternalZMax; } + Float_t GetTransitionEta() const; Float_t GetTransitionTheta() const; @@ -91,13 +100,13 @@ public: Float_t GetEtaMax() const {return fEtaMax;} Float_t GetEtaRng() const {return fEtaMax-fEtaMin;} - virtual void SetPhi(Float_t phi) { SetPhiWithRng(phi, fPhiRng); } + virtual void SetPhi(Float_t phi) { SetPhiWithRng(phi, fPhiOffset); } virtual void SetPhiRng(Float_t rng) { SetPhiWithRng(fPhi, rng); } virtual void SetPhiWithRng(Float_t x, Float_t r); Float_t GetPhi() const { return fPhi;} - Float_t GetPhiMin() const {return fPhi-fPhiRng;} - Float_t GetPhiMax() const {return fPhi+fPhiRng;} - Float_t GetPhiRng() const {return fPhiRng;} + Float_t GetPhiMin() const {return fPhi-fPhiOffset;} + Float_t GetPhiMax() const {return fPhi+fPhiOffset;} + Float_t GetPhiRng() const {return fPhiOffset*2;} virtual void ResetCache() = 0; diff --git a/graf3d/eve/inc/TEveCaloVizEditor.h b/graf3d/eve/inc/TEveCaloVizEditor.h index 1ab7a1a956b..33d3fd5eb21 100644 --- a/graf3d/eve/inc/TEveCaloVizEditor.h +++ b/graf3d/eve/inc/TEveCaloVizEditor.h @@ -33,7 +33,7 @@ protected: TEveGDoubleValuator *fEtaRng; TEveGValuator *fPhi; - TEveGValuator *fPhiRng; + TEveGValuator *fPhiOffset; TGVerticalFrame *fTower; TEveRGBAPaletteSubEditor *fPalette; // Palette sub-editor.x diff --git a/graf3d/eve/src/TEveCalo.cxx b/graf3d/eve/src/TEveCalo.cxx index 9fa4bed96bc..cc7bf5b8094 100644 --- a/graf3d/eve/src/TEveCalo.cxx +++ b/graf3d/eve/src/TEveCalo.cxx @@ -46,13 +46,16 @@ TEveCaloViz::TEveCaloViz(const Text_t* n, const Text_t* t) : fEtaMax(1), fPhi(0.), - fPhiRng(TMath::Pi()), + fPhiOffset(TMath::Pi()), fBarrelRadius(-1.f), fEndCapPos(-1.f), fCellZScale(1.), + fUseExternalZMax(kFALSE), + fExternalZMax(1), + fValueIsColor(kTRUE), fPalette(0), @@ -74,13 +77,16 @@ TEveCaloViz::TEveCaloViz(TEveCaloData* data, const Text_t* n, const Text_t* t) : fEtaMax(1), fPhi(0.), - fPhiRng(TMath::Pi()), + fPhiOffset(TMath::Pi()), fBarrelRadius(-1.f), fEndCapPos(-1.f), fCellZScale(1.), + fUseExternalZMax(kFALSE), + fExternalZMax(1), + fValueIsColor(kTRUE), fPalette(0), @@ -122,7 +128,7 @@ void TEveCaloViz::SetPhiWithRng(Float_t phi, Float_t rng) using namespace TMath; fPhi = phi; - fPhiRng = rng; + fPhiOffset = rng; InvalidateCache(); } @@ -160,7 +166,7 @@ void TEveCaloViz::SetData(TEveCaloData* data) Double_t min, max; fData->GetPhiLimits(min, max); fPhi = (max+min)*0.5; - fPhiRng =(max-min)*0.5; + fPhiOffset =(max-min)*0.5; InvalidateCache(); } @@ -176,7 +182,7 @@ void TEveCaloViz::AssignCaloVizParameters(TEveCaloViz* m) fEtaMax = m->fEtaMax; fPhi = m->fPhi; - fPhiRng = m->fPhiRng; + fPhiOffset = m->fPhiOffset; fBarrelRadius = m->fBarrelRadius; fEndCapPos = m->fEndCapPos; @@ -463,7 +469,12 @@ Float_t TEveCaloLego::GetDefaultCellHeight() const { // Get default cell height. - return TMath::TwoPi(); + Float_t h = 10; + + if (fUseExternalZMax) + h *= (fData->GetMaxVal()/fExternalZMax); + + return h; } //______________________________________________________________________________ @@ -483,21 +494,36 @@ void TEveCaloLego::ComputeBBox() BBoxInit(); // Float_t[6] X(min,max), Y(min,max), Z(min,max) + if (fData) { Float_t ex = 1.2; + Float_t a = 0.5*GetDefaultCellHeight()*ex; + + fBBox[0] = -a; + fBBox[1] = a; + fBBox[2] = -a; + fBBox[3] = a; + + // scaling is relative to shortest XY axis Double_t em, eM, pm, pM; fData->GetEtaLimits(em, eM); fData->GetPhiLimits(pm, pM); + Double_t r = (eM-em)/(pM-pm); + if (r<1) + { + fBBox[2] /= r; + fBBox[3] /= r; + } + else + { + fBBox[0] *= r; + fBBox[1] *= r; + } - fBBox[0] = ex*em; - fBBox[1] = ex*eM; - - fBBox[2] = ex*pm; - fBBox[3] = ex*pM; - - fBBox[4] = -GetDefaultCellHeight()*fCellZScale*0.2; - fBBox[5] = GetDefaultCellHeight()*fCellZScale*1.2; + fBBox[4] = GetDefaultCellHeight()*fCellZScale*(1-ex); + fBBox[5] = GetDefaultCellHeight()*fCellZScale*ex; } } + diff --git a/graf3d/eve/src/TEveCalo2DGL.cxx b/graf3d/eve/src/TEveCalo2DGL.cxx index 1cc8b1af6ea..b1421bcd164 100644 --- a/graf3d/eve/src/TEveCalo2DGL.cxx +++ b/graf3d/eve/src/TEveCalo2DGL.cxx @@ -271,7 +271,7 @@ void TEveCalo2DGL::DrawRhoZ(TGLRnrCtx & rnrCtx) const TEveCaloData::vCellId_t* aa = new TEveCaloData::vCellId_t(); data->GetCellList(fM->fPalette->GetMinVal(), fM->fPalette->GetMaxVal(), fM->GetEta() + ax->GetBinCenter(ibin), ax->GetBinWidth(ibin), - fM->fPhi, fM->fPhiRng, *aa); + fM->fPhi, fM->fPhiOffset, *aa); if (aa->size()) fM->fCellLists.push_back(aa); } } diff --git a/graf3d/eve/src/TEveCaloLegoGL.cxx b/graf3d/eve/src/TEveCaloLegoGL.cxx index a99fb5a4868..dd584245147 100644 --- a/graf3d/eve/src/TEveCaloLegoGL.cxx +++ b/graf3d/eve/src/TEveCaloLegoGL.cxx @@ -227,7 +227,7 @@ void TEveCaloLegoGL::MakeDisplayList() const prevTower = fM->fCellList[i].fTower; } - fM->fData->GetCellData(fM->fCellList[i], fM->fPhi, fM->fPhiRng, cellData); + fM->fData->GetCellData(fM->fCellList[i], fM->fPhi, fM->fPhiOffset, cellData); if (s == fM->fCellList[i].fSlice) { glLoadName(i); @@ -546,7 +546,7 @@ void TEveCaloLegoGL::DrawZScales3D(TGLRnrCtx & rnrCtx, { // left most corner of the picked tower TEveCaloData::CellData_t cd; - fM->fData->GetCellData(fM->fCellList[fTowerPicked], fM->fPhi, fM->fPhiRng, cd); + fM->fData->GetCellData(fM->fCellList[fTowerPicked], fM->fPhi, fM->fPhiOffset, cd); switch(idxLeft) { case 0: @@ -624,14 +624,22 @@ void TEveCaloLegoGL::DrawXYScales(TGLRnrCtx & rnrCtx, Float_t zOff = -fDataMax*0.03; Float_t zOff2 = zOff*0.5; + + Float_t yOff = 0.03*TMath::Sign(y1-y0, axY); + Float_t xOff = 0.03*TMath::Sign(x1-x0, ayX); + Float_t rxy = (fPhiAxis->GetXmax()-fPhiAxis->GetXmin())/(fEtaAxis->GetXmax()-fEtaAxis->GetXmin()); + if (rxy>1) + { + yOff /= rxy; + } + else + { + xOff *=rxy; + } - Float_t rxy = (fEtaAxis->GetXmax()-fEtaAxis->GetXmin())/(fPhiAxis->GetXmax()-fPhiAxis->GetXmin()); - Float_t yOff = 0.03*TMath::Sign(y1-y0, axY)/rxy; - Float_t yOff2 = yOff*0.5; - - Float_t xOff = 0.03*TMath::Sign(x1-x0, ayX)*rxy; Float_t xOff2 = xOff*0.5; + Float_t yOff2 = yOff*0.5; glPushMatrix(); glTranslatef(0, 0, zOff); @@ -756,42 +764,50 @@ void TEveCaloLegoGL::DrawXYScales(TGLRnrCtx & rnrCtx, Int_t TEveCaloLegoGL::GetGridStep(Int_t axId, TGLRnrCtx &rnrCtx) const { // Calculate view-dependent grid density. - GLdouble xp0, yp0, zp0, xp1, yp1, zp1; + + GLdouble x0, y0, z0, x1, y1, z1; + GLdouble mm[16]; GLint vp[4]; glGetDoublev(GL_MODELVIEW_MATRIX, mm); glGetIntegerv(GL_VIEWPORT, vp); const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr(); - Int_t firstX = fEtaAxis->GetFirst(); - Int_t lastX = fEtaAxis->GetLast(); - Int_t firstY = fPhiAxis->GetFirst(); - Int_t lastY = fPhiAxis->GetLast(); if (axId == 0) { - Float_t y0 = fPhiAxis->GetBinLowEdge(firstY); - for (Int_t idx = 0; idx < fNBinSteps; ++idx) + Int_t firstX = fEtaAxis->GetFirst(); + Int_t lastX = fEtaAxis->GetLast(); + + for (Int_t i=0; i<fNBinSteps; ++i) { - if (firstX + fBinSteps[idx] > lastX) return 1; - gluProject(fEtaAxis->GetBinLowEdge(firstX), y0, 0, mm, pm, vp, &xp0, &yp0, &zp0); - gluProject(fEtaAxis->GetBinLowEdge(firstX+fBinSteps[idx]), y0, 0, mm, pm, vp, &xp1, &yp1, &zp1); - Float_t gapsqr = (xp0-xp1)*(xp0-xp1) + (yp0-yp1)*(yp0-yp1); + if (firstX+fBinSteps[i] > lastX) + return TMath::Max(i-1, 1); + + gluProject(fEtaAxis->GetBinLowEdge(firstX), fM->GetPhi(), 0, mm, pm, vp, &x0, &y0, &z0); + gluProject(fEtaAxis->GetBinLowEdge(firstX+fBinSteps[i]), fM->GetPhi(), 0, mm, pm, vp, &x1, &y1, &z1); + + Float_t gapsqr = (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1); if (gapsqr > fM->fBinWidth*fM->fBinWidth) - return fBinSteps[idx]; + return fBinSteps[i]; } } else if (axId == 1) { - Float_t x0 = fEtaAxis->GetBinLowEdge(firstX); - for (Int_t idx = firstY; idx < fNBinSteps; ++idx) - { - if (firstY + fBinSteps[idx] > lastY) return 1; - gluProject(x0, fEtaAxis->GetBinLowEdge(firstY), 0, mm, pm, vp, &xp0, &yp0, &zp0); - gluProject(x0, fEtaAxis->GetBinLowEdge(firstY+fBinSteps[idx]), 0, mm, pm, vp, &xp1, &yp1, &zp1); - Float_t gapsqr = (xp0-xp1)*(xp0-xp1) + (yp0-yp1)*(yp0-yp1); + Double_t bw = fPhiAxis->GetBinWidth(1); + Float_t phi = bw*TMath::CeilNint(fM->GetPhiMin()/bw); + for (Int_t i=0; i<fNBinSteps; ++i) + { + Float_t ps = fBinSteps[i]*bw; + if (phi+ps > fM->GetPhiMax()) + return fBinSteps[TMath::Max(i-1, 1)]; + + gluProject(fM->GetEta(), phi, 0, mm, pm, vp, &x0, &y0, &z0); + gluProject(fM->GetEta(), phi+ps, 0, mm, pm, vp, &x1, &y1, &z1); + + Float_t gapsqr = (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1); if (gapsqr > fM->fBinWidth*fM->fBinWidth) - return fBinSteps[idx]; + return fBinSteps[i]; } } return 1; @@ -802,6 +818,8 @@ void TEveCaloLegoGL::DrawHistBase(TGLRnrCtx &rnrCtx) const { // Draw basic histogram components: x-y grid + using namespace TMath; + Int_t es = GetGridStep(0, rnrCtx); Int_t ps = GetGridStep(1, rnrCtx); @@ -835,12 +853,6 @@ void TEveCaloLegoGL::DrawHistBase(TGLRnrCtx &rnrCtx) const glVertex2f(fEtaAxis->GetBinUpEdge(i), phi0); glVertex2f(fEtaAxis->GetBinUpEdge(i), phi1); } - - for (Int_t i=fPhiAxis->GetFirst(); i<fPhiAxis->GetLast(); i+= es) - { - glVertex2f(eta0, fEtaAxis->GetBinUpEdge(i)); - glVertex2f(eta1, fEtaAxis->GetBinUpEdge(i)); - } } else { @@ -853,15 +865,16 @@ void TEveCaloLegoGL::DrawHistBase(TGLRnrCtx &rnrCtx) const glVertex2f(i*ebw, phi0); glVertex2f(i*ebw, phi1); } + } - Float_t pbw = ps*(phi1-phi0)/fPhiAxis->GetNbins(); - Int_t j0 = Int_t(phi0/pbw); - Int_t j1 = Int_t(phi1/pbw); - for (Int_t j=j0; j<=j1; j++) - { - glVertex2f(eta0, j*pbw); - glVertex2f(eta1, j*pbw); - } + //phi + Double_t phiW = ps*fPhiAxis->GetBinWidth(1); + Float_t phi = phiW*CeilNint(phi0/phiW); + while (phi < phi1) + { + glVertex2f(eta0, phi); + glVertex2f(eta1, phi); + phi+=phiW; } glEnd(); @@ -927,7 +940,7 @@ void TEveCaloLegoGL::DrawCells2D(TGLRnrCtx & rnrCtx) const for (TEveCaloData::vCellId_t::iterator it=fM->fCellList.begin(); it!=fM->fCellList.end(); it++) { - fM->fData->GetCellData(*it, fM->fPhi, fM->fPhiRng, cellData); + fM->fData->GetCellData(*it, fM->fPhi, fM->fPhiOffset, cellData); glLoadName(name); glBegin(GL_QUADS); if ((*it).fTower != prevTower) @@ -984,7 +997,7 @@ void TEveCaloLegoGL::DrawCells2D(TGLRnrCtx & rnrCtx) const Float_t left, right, up, down; // cell corners for (TEveCaloData::vCellId_t::iterator it=fM->fCellList.begin(); it!=fM->fCellList.end(); it++) { - fM->fData->GetCellData(*it, fM->fPhi, fM->fPhiRng, cd); + fM->fData->GetCellData(*it, fM->fPhi, fM->fPhiOffset, cd); Int_t iMin = FloorNint((cd.EtaMin()- eta0)/etaStep); Int_t iMax = CeilNint ((cd.EtaMax()- eta0)/etaStep); Int_t jMin = FloorNint((cd.PhiMin()- phi0)/phiStep); @@ -1097,19 +1110,29 @@ void TEveCaloLegoGL::DirectDraw(TGLRnrCtx & rnrCtx) const fM->ResetCache(); fM->fData->GetCellList(fM->fPalette->GetMinVal(), fM->fPalette->GetMaxVal(), fM->GetEta(), fM->GetEtaRng()*0.5, - fM->fPhi, fM->fPhiRng, fM->fCellList); + fM->fPhi, fM->fPhiOffset, fM->fCellList); fM->fCacheOK = kTRUE; } if (cells3D && fDLCacheOK == kFALSE) MakeDisplayList(); - // set modelview matrix + // modelview matrix glPushMatrix(); - glTranslatef(0, -fM->fPhi, 0); - glScalef((fEtaAxis->GetXmax()-fEtaAxis->GetXmin())/fM->GetEtaRng(), - 0.5*(fPhiAxis->GetXmax()-fPhiAxis->GetXmin())/fM->fPhiRng, - fM->fCellZScale*fM->GetDefaultCellHeight()/fZAxisMax); + // scale from rebinning + Float_t sx = (fEtaAxis->GetXmax()-fEtaAxis->GetXmin())/fM->GetEtaRng(); + Float_t sy = (fPhiAxis->GetXmax()-fPhiAxis->GetXmin())/fM->GetPhiRng(); + + // scale due to shortest XY axis have same length as z axis + Float_t zf; + if (fEtaAxis->GetXmax()-fEtaAxis->GetXmin() < fPhiAxis->GetXmax()-fPhiAxis->GetXmin()) + zf = fM->GetDefaultCellHeight()/(fEtaAxis->GetXmax()-fEtaAxis->GetXmin()); + else + zf = fM->GetDefaultCellHeight()/(fPhiAxis->GetXmax()-fPhiAxis->GetXmin()); + + glScalef(sx*zf, sy*zf, fM->fCellZScale*fM->GetDefaultCellHeight()/fZAxisMax); + + glTranslatef(-fM->GetEta(), -fM->fPhi, 0); glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT); glLineWidth(1); diff --git a/graf3d/eve/src/TEveCaloVizEditor.cxx b/graf3d/eve/src/TEveCaloVizEditor.cxx index b8039e16f27..bf2044cd8d8 100644 --- a/graf3d/eve/src/TEveCaloVizEditor.cxx +++ b/graf3d/eve/src/TEveCaloVizEditor.cxx @@ -37,7 +37,7 @@ TEveCaloVizEditor::TEveCaloVizEditor(const TGWindow *p, Int_t width, Int_t heigh fEtaRng(0), fPhi(0), - fPhiRng(0), + fPhiOffset(0), fTower(0), fPalette(0), fCellZScale(0) @@ -66,13 +66,13 @@ TEveCaloVizEditor::TEveCaloVizEditor(const TGWindow *p, Int_t width, Int_t heigh fPhi->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()"); fTower->AddFrame(fPhi, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); - fPhiRng = new TEveGValuator(fTower, "PhiRng:", 90, 0); - fPhiRng->SetLabelWidth(labelW); - fPhiRng->SetNELength(6); - fPhiRng->Build(); - fPhiRng->SetLimits(0, 180); - fPhiRng->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()"); - fTower->AddFrame(fPhiRng, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); + fPhiOffset = new TEveGValuator(fTower, "PhiOff:", 90, 0); + fPhiOffset->SetLabelWidth(labelW); + fPhiOffset->SetNELength(6); + fPhiOffset->Build(); + fPhiOffset->SetLimits(0, 180); + fPhiOffset->Connect("ValueSet(Double_t)", "TEveCaloVizEditor", this, "DoPhi()"); + fTower->AddFrame(fPhiOffset, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); fCellZScale = new TEveGValuator(fTower, "ZScale:", 90, 0); fCellZScale->SetLabelWidth(labelW); @@ -107,7 +107,7 @@ void TEveCaloVizEditor::SetModel(TObject* obj) fEtaRng->SetValues(fM->fEtaMin, fM->fEtaMax); fPhi->SetValue(fM->fPhi*TMath::RadToDeg()); - fPhiRng->SetValue(fM->fPhiRng*TMath::RadToDeg()); + fPhiOffset->SetValue(fM->fPhiOffset*TMath::RadToDeg()); fPalette->SetModel(fM->fPalette); @@ -128,7 +128,7 @@ void TEveCaloVizEditor::DoPhi() { // Slot for setting phi range. - fM->SetPhiWithRng(fPhi->GetValue()*TMath::DegToRad(), fPhiRng->GetValue()*TMath::DegToRad()); + fM->SetPhiWithRng(fPhi->GetValue()*TMath::DegToRad(), fPhiOffset->GetValue()*TMath::DegToRad()); Update(); } diff --git a/tutorials/eve/cms_calo.C b/tutorials/eve/cms_calo.C index 6424fcdfafd..8f94dca5465 100644 --- a/tutorials/eve/cms_calo.C +++ b/tutorials/eve/cms_calo.C @@ -69,46 +69,42 @@ void MakeCalo2D(TEveCalo3D* calo3d) void MakeCaloLego(TEveCaloDataHist* data) { TEveViewer* v2 = gEve->SpawnNewViewer("Lego Viewer"); - TGLViewer* v = v2->GetGLViewer(); + TGLViewer* v = v2->GetGLViewer(); v->SetCurrentCamera(TGLViewer::kCameraPerspXOY); v->SetEventHandler(new TEveLegoEventHandler("Lego", v->GetGLWidget(), v)); - - // histogram TEveRGBAPalette* pal = new TEveRGBAPalette(0, 100); pal->SetLimits(0, TMath::CeilNint(data->GetMaxVal())); pal->SetDefaultColor((Color_t)4); TEveScene* s2 = gEve->SpawnNewScene("Lego"); v2->AddScene(s2); + + // lego1 TEveCaloLego* lego = new TEveCaloLego(data); lego->SetPalette(pal); lego->SetGridColor(kGray+2); lego->Set2DMode(TEveCaloLego::kValSize); + lego->SetName("TwoHistLego"); gEve->AddElement(lego, s2); gEve->AddToListTree(lego, kTRUE); - - // random lines to demonstrate TEveLegoEventHandler - TRandom r(0); - gStyle->SetPalette(1, 0); - TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130); - TEveQuadSet* q = new TEveQuadSet("LineXYFixedZ"); - q->SetPalette(pal); - q->Reset(TEveQuadSet::kQT_LineXYFixedZ, kFALSE, 32); - for (Int_t i=0; i<10; ++i) { - q->AddLine(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), - r.Uniform(0.2, 1)); - q->QuadValue(r.Uniform(0, 130)); - } - q->RefitPlex(); - TEveTrans& t = q->RefMainTrans(); - Float_t sc = 0.3; - t.SetScale(sc, sc, sc); - gEve->AddElement(q, s2); - // overlay + // overlay lego1 gEve->DisableRedraw(); TEveLegoOverlay* overlay = new TEveLegoOverlay(); overlay->SetCaloLego(lego); v->AddOverlayElement(overlay); gEve->AddElement(overlay, s2); gEve->EnableRedraw(); + + // lego2 + TEveCaloDataHist* data2 = new TEveCaloDataHist(); + data2->AddHistogram(data->GetHistogram(0)); + TEveCaloLego* lego2 = new TEveCaloLego(data2); + lego2->SetName("OneHistLego"); + lego2->SetPalette(pal); + gEve->AddElement(lego2, s2); + gEve->AddToListTree(lego2, kTRUE); + lego2->InitMainTrans(); + lego2->RefMainTrans().Move3PF(0, 0, 15); + lego2->SetEta(-3, 3); + lego2->SetPhi(TMath::PiOver4()); } -- GitLab