TEveCalo.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveCalo.cxx 37345 2010-12-06 16:53:39Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveCalo.h"
00013 #include "TEveCaloData.h"
00014 #include "TEveProjections.h"
00015 #include "TEveProjectionManager.h"
00016 #include "TEveRGBAPalette.h"
00017 #include "TEveText.h"
00018 #include "TEveTrans.h"
00019 
00020 #include "TClass.h"
00021 #include "TMathBase.h"
00022 #include "TMath.h"
00023 #include "TAxis.h"
00024 
00025 #include "TGLUtil.h"
00026 
00027 #include <cassert>
00028 
00029 //==============================================================================
00030 // TEveCaloViz
00031 //==============================================================================
00032 
00033 //______________________________________________________________________________
00034 //
00035 // Base class for calorimeter data visualization.
00036 // See TEveCalo2D and TEveCalo3D for concrete implementations.
00037 
00038 ClassImp(TEveCaloViz);
00039 
00040 //______________________________________________________________________________
00041 TEveCaloViz::TEveCaloViz(TEveCaloData* data, const char* n, const char* t) :
00042    TEveElement(),
00043    TNamed(n, t),
00044    TEveProjectable(),
00045 
00046    fData(0),
00047    fCellIdCacheOK(kFALSE),
00048 
00049    fEtaMin(-10),
00050    fEtaMax(10),
00051 
00052    fPhi(0.),
00053    fPhiOffset(TMath::Pi()),
00054 
00055    fAutoRange(kTRUE),
00056 
00057    fBarrelRadius(-1.f),
00058    fEndCapPos(-1.f),
00059 
00060    fPlotEt(kTRUE),
00061 
00062    fMaxTowerH(100),
00063    fScaleAbs(kFALSE),
00064    fMaxValAbs(100),
00065 
00066    fValueIsColor(kFALSE),
00067    fPalette(0)
00068 {
00069    // Constructor.
00070 
00071    fPickable = kTRUE;
00072    SetElementNameTitle(n, t);
00073    SetData(data);
00074 }
00075 
00076 //______________________________________________________________________________
00077 TEveCaloViz::~TEveCaloViz()
00078 {
00079    // Destructor.
00080 
00081    if (fPalette) fPalette->DecRefCount();
00082 }
00083 
00084 //______________________________________________________________________________
00085 Float_t TEveCaloViz::GetDataSliceThreshold(Int_t slice) const
00086 {
00087    // Get threshold for given slice.
00088 
00089    return fData->RefSliceInfo(slice).fThreshold;
00090 }
00091 
00092 //______________________________________________________________________________
00093 TEveElement* TEveCaloViz::ForwardSelection()
00094 {
00095    // Management of selection state and ownership of selected cell list
00096    // is done in TEveCaloData. This is a reason selection is forwared to it.
00097 
00098    return fData;
00099 }
00100 
00101 //______________________________________________________________________________
00102 TEveElement* TEveCaloViz::ForwardEdit()
00103 {
00104    // Management of selection state and ownership of selected cell list
00105    // is done in TEveCaloData. We still want GUI editor to disply
00106    // concrete calo-viz object.
00107 
00108    return this;
00109 }
00110 
00111 //______________________________________________________________________________
00112 void TEveCaloViz::SetDataSliceThreshold(Int_t slice, Float_t val)
00113 {
00114    // Set threshold for given slice.
00115 
00116    fData->SetSliceThreshold(slice, val);
00117 }
00118 
00119 //______________________________________________________________________________
00120 Color_t TEveCaloViz::GetDataSliceColor(Int_t slice) const
00121 {
00122    // Get slice color from data.
00123 
00124    return fData->RefSliceInfo(slice).fColor;
00125 }
00126 
00127 //______________________________________________________________________________
00128 void TEveCaloViz::SetDataSliceColor(Int_t slice, Color_t col)
00129 {
00130    // Set slice color in data.
00131 
00132    fData->SetSliceColor(slice, col);
00133 }
00134 
00135 //______________________________________________________________________________
00136 void TEveCaloViz::SetEta(Float_t l, Float_t u)
00137 {
00138    // Set eta range.
00139 
00140    fEtaMin=l;
00141    fEtaMax=u;
00142 
00143    InvalidateCellIdCache();
00144 }
00145 
00146 //______________________________________________________________________________
00147 void TEveCaloViz::SetPlotEt(Bool_t isEt)
00148 {
00149    // Set E/Et plot.
00150 
00151    fPlotEt=isEt;
00152    if (fPalette)
00153       fPalette->SetLimits(0, TMath::CeilNint(GetMaxVal()));
00154 
00155    InvalidateCellIdCache();
00156 }
00157 
00158 //______________________________________________________________________________
00159 Float_t TEveCaloViz::GetMaxVal() const
00160 {
00161 
00162    // Get maximum plotted value.
00163 
00164    return fData->GetMaxVal(fPlotEt);
00165 
00166 }
00167 
00168 //______________________________________________________________________________
00169 void TEveCaloViz::SetPhiWithRng(Float_t phi, Float_t rng)
00170 {
00171    // Set phi range.
00172 
00173    using namespace TMath;
00174 
00175    fPhi = phi;
00176    fPhiOffset = rng;
00177 
00178    InvalidateCellIdCache();
00179 }
00180 
00181 //______________________________________________________________________________
00182 Float_t TEveCaloViz::GetTransitionTheta() const
00183 {
00184    // Get transition angle between barrel and end-cap cells.
00185 
00186    return TMath::ATan(fBarrelRadius/fEndCapPos);
00187 }
00188 
00189 //______________________________________________________________________________
00190 Float_t TEveCaloViz::GetTransitionEta() const
00191 {
00192    // Get transition eta between barrel and end-cap cells.
00193 
00194    using namespace TMath;
00195    Float_t t = GetTransitionTheta()*0.5f;
00196    return -Log(Tan(t));
00197 }
00198 
00199 //______________________________________________________________________________
00200 void TEveCaloViz::SetData(TEveCaloData* data)
00201 {
00202    // Set calorimeter event data.
00203 
00204 
00205    if (data == fData) return;
00206    if (fData) fData->RemoveElement(this);
00207    fData = data;
00208    if (fData)
00209    {
00210       fData->AddElement(this);
00211       DataChanged();
00212    }
00213 }
00214 
00215 //______________________________________________________________________________
00216 void TEveCaloViz::DataChanged()
00217 {
00218    // Update setting and cache on data changed.
00219    // Called from TEvecaloData::BroadcastDataChange()
00220 
00221    Double_t min, max, delta;
00222 
00223    fData->GetEtaLimits(min, max);
00224    if (fAutoRange) {
00225       fEtaMin = min;
00226       fEtaMax = max;
00227    } else {
00228       if (fEtaMin < min) fEtaMin = min;
00229       if (fEtaMax > max) fEtaMax = max;
00230    }
00231 
00232    fData->GetPhiLimits(min, max);
00233    delta = 0.5*(max - min);
00234    if (fAutoRange || fPhi < min || fPhi > max) {
00235       fPhi       = 0.5*(max + min);
00236       fPhiOffset = delta;
00237    } else {
00238       if (fPhiOffset > delta) fPhiOffset = delta;
00239    }
00240 
00241    if (fPalette)
00242    {
00243       Int_t hlimit = TMath::CeilNint(GetMaxVal());
00244       fPalette->SetLimits(0, hlimit);
00245       fPalette->SetMin(0);
00246       fPalette->SetMax(hlimit);
00247    }
00248 
00249    InvalidateCellIdCache();
00250 }
00251 
00252 //______________________________________________________________________________
00253 Bool_t TEveCaloViz::AssertCellIdCache() const
00254 {
00255    // Assert cell id cache is ok.
00256    // Returns true if the cache has been updated.
00257  
00258    TEveCaloViz* cv = const_cast<TEveCaloViz*>(this);
00259    if (!fCellIdCacheOK) {
00260       cv->BuildCellIdCache();
00261       return kTRUE;
00262    } else {
00263       return kFALSE;
00264    }
00265 }
00266 
00267 //______________________________________________________________________________
00268 Bool_t TEveCaloViz::CellInEtaPhiRng(TEveCaloData::CellData_t& cellData) const
00269 {
00270    // Returns true if given cell is in the ceta phi range.
00271 
00272    if (cellData.EtaMin() >= fEtaMin && cellData.EtaMax() <= fEtaMax)
00273    {
00274       if (TEveUtil::IsU1IntervalContainedByMinMax
00275           (fPhi-fPhiOffset, fPhi+fPhiOffset, cellData.PhiMin(), cellData.PhiMax()))
00276          return kTRUE;
00277    }
00278    return kFALSE;
00279 }
00280 
00281 //______________________________________________________________________________
00282 void TEveCaloViz::AssignCaloVizParameters(TEveCaloViz* m)
00283 {
00284    // Assign paramteres from given model.
00285 
00286    SetData(m->fData);
00287 
00288    fEtaMin    = m->fEtaMin;
00289    fEtaMax    = m->fEtaMax;
00290 
00291    fPhi       = m->fPhi;
00292    fPhiOffset = m->fPhiOffset;
00293 
00294    fBarrelRadius = m->fBarrelRadius;
00295    fEndCapPos    = m->fEndCapPos;
00296 
00297    if (m->fPalette)
00298    {
00299       TEveRGBAPalette& mp = * m->fPalette;
00300       if (fPalette) fPalette->DecRefCount();
00301       fPalette = new TEveRGBAPalette(mp.GetMinVal(), mp.GetMaxVal(), mp.GetInterpolate());
00302       fPalette->SetDefaultColor(mp.GetDefaultColor());
00303    }
00304 }
00305 
00306 //______________________________________________________________________________
00307 void TEveCaloViz::SetPalette(TEveRGBAPalette* p)
00308 {
00309    // Set TEveRGBAPalette object pointer.
00310 
00311    if ( fPalette == p) return;
00312    if (fPalette) fPalette->DecRefCount();
00313    fPalette = p;
00314    if (fPalette) fPalette->IncRefCount();
00315 }
00316 
00317 //______________________________________________________________________________
00318 Float_t TEveCaloViz::GetValToHeight() const
00319 {
00320    // Get transformation factor from E/Et to height
00321 
00322    if (fScaleAbs)
00323    {
00324       return fMaxTowerH/fMaxValAbs;
00325    }
00326    else
00327    {
00328      if (fData->Empty())
00329        return 1;
00330 
00331       return fMaxTowerH/fData->GetMaxVal(fPlotEt);
00332    }
00333 }
00334 
00335 //______________________________________________________________________________
00336 TEveRGBAPalette* TEveCaloViz::AssertPalette()
00337 {
00338    // Make sure the TEveRGBAPalette pointer is not null.
00339    // If it is not set, a new one is instantiated and the range is set
00340    // to current min/max signal values.
00341 
00342    if (fPalette == 0) {
00343       fPalette = new TEveRGBAPalette;
00344       fPalette->SetDefaultColor((Color_t)4);
00345 
00346       Int_t hlimit = TMath::CeilNint(GetMaxVal());
00347       fPalette->SetLimits(0, hlimit);
00348       fPalette->SetMin(0);
00349       fPalette->SetMax(hlimit);
00350 
00351    }
00352    return fPalette;
00353 }
00354 
00355 //______________________________________________________________________________
00356 void TEveCaloViz::Paint(Option_t* /*option*/)
00357 {
00358    // Paint this object. Only direct rendering is supported.
00359 
00360    if (fData)
00361    {
00362       PaintStandard(this);
00363    }
00364 }
00365 
00366 //______________________________________________________________________________
00367 TClass* TEveCaloViz::ProjectedClass(const TEveProjection*) const
00368 {
00369    // Virtual from TEveProjectable, returns TEveCalo2D class.
00370 
00371    return TEveCalo2D::Class();
00372 }
00373 
00374 //______________________________________________________________________________
00375 void TEveCaloViz::SetupColorHeight(Float_t value, Int_t slice, Float_t& outH) const
00376 {
00377    // Set color and height for a given value and slice using slice color or TEveRGBAPalette.
00378 
00379    if (fValueIsColor)
00380    {
00381       outH = GetValToHeight()*fData->GetMaxVal(fPlotEt);
00382       UChar_t c[4];
00383       fPalette->ColorFromValue((Int_t)value, c);
00384       c[3] = fData->GetSliceTransparency(slice);
00385       TGLUtil::Color4ubv(c);
00386    }
00387    else
00388    {
00389       TGLUtil::ColorTransparency(fData->GetSliceColor(slice), fData->GetSliceTransparency(slice));
00390       outH = GetValToHeight()*value;
00391    }
00392 }
00393 
00394 
00395 //==============================================================================
00396 // TEveCalo3D
00397 //==============================================================================
00398 
00399 //______________________________________________________________________________
00400 //
00401 // Visualization of a calorimeter event data in 3D.
00402 
00403 ClassImp(TEveCalo3D);
00404 
00405 
00406 TEveCalo3D::TEveCalo3D(TEveCaloData* d, const char* n, const char* t):
00407    TEveCaloViz(d, n, t),
00408 
00409    fRnrEndCapFrame    (kTRUE),
00410    fRnrBarrelFrame    (kTRUE),
00411    fFrameWidth        (0.5),
00412    fFrameColor        (kGray+1),
00413    fFrameTransparency (80)
00414 {
00415 
00416    // Constructor.
00417 
00418    fCanEditMainColor        = kTRUE;
00419    fCanEditMainTransparency = kTRUE;
00420    fMainColorPtr = &fFrameColor;
00421 }
00422 
00423 //______________________________________________________________________________
00424 void TEveCalo3D::BuildCellIdCache()
00425 {
00426    // Build list of drawn cell IDs. See TEveCalo3DGL::DirectDraw().
00427 
00428    fCellList.clear();
00429 
00430    fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
00431    fCellIdCacheOK = kTRUE;
00432 }
00433 
00434 //______________________________________________________________________________
00435 void TEveCalo3D::ComputeBBox()
00436 {
00437    // Fill bounding-box information of the base-class TAttBBox (virtual method).
00438    // If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
00439 
00440    BBoxInit();
00441 
00442    Float_t th = (fData) ? GetValToHeight() * fData->GetMaxVal(fPlotEt) : 0;
00443 
00444    fBBox[0] = -fBarrelRadius - th;
00445    fBBox[1] =  fBarrelRadius + th;
00446    fBBox[2] =  fBBox[0];
00447    fBBox[3] =  fBBox[1];
00448    fBBox[4] = -fEndCapPos - th;
00449    fBBox[5] =  fEndCapPos + th;
00450 }
00451 
00452 
00453 //==============================================================================
00454 // TEveCalo2D
00455 //==============================================================================
00456 
00457 //______________________________________________________________________________
00458 //
00459 // Visualization of a calorimeter event data in 2D.
00460 
00461 ClassImp(TEveCalo2D);
00462 
00463 //______________________________________________________________________________
00464 TEveCalo2D::TEveCalo2D(const char* n, const char* t):
00465    TEveCaloViz(0, n, t),
00466    TEveProjected(),
00467    fOldProjectionType(TEveProjection::kPT_Unknown),
00468    fMaxESumBin( 0),
00469    fMaxEtSumBin(0)
00470 {
00471    // Constructor.
00472 }
00473 
00474 //______________________________________________________________________________
00475 TEveCalo2D::~TEveCalo2D()
00476 {
00477    // Destructor.
00478 
00479    TEveCaloData::vCellId_t* cids;
00480    UInt_t n;
00481 
00482    // clear selected cell ids
00483    n = fCellListsSelected.size();
00484    for(UInt_t i = 0; i < n; ++i) {
00485       cids = fCellListsSelected[i];
00486       if (cids) {
00487          cids->clear(); delete cids;
00488       }
00489    }
00490    fCellListsSelected.clear();
00491 
00492    // clear all cell dds
00493    n = fCellLists.size();
00494    for(UInt_t i = 0; i < n; ++i) {
00495       cids = fCellLists[i];
00496       if (cids) {
00497          cids->clear(); delete cids;
00498       }
00499    }
00500    fCellLists.clear();
00501 }
00502 
00503 //______________________________________________________________________________
00504 void TEveCalo2D::UpdateProjection()
00505 {
00506    // This is virtual method from base-class TEveProjected.
00507 
00508    if (fManager->GetProjection()->GetType() != fOldProjectionType)
00509    {
00510       fCellIdCacheOK=kFALSE;
00511       fOldProjectionType = fManager->GetProjection()->GetType();
00512    }
00513    ComputeBBox();
00514 }
00515 
00516 //______________________________________________________________________________
00517 void TEveCalo2D::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
00518 {
00519    // Set projection manager and model object.
00520 
00521    TEveProjected::SetProjection(mng, model);
00522    TEveCaloViz* viz = dynamic_cast<TEveCaloViz*>(model);
00523    AssignCaloVizParameters(viz);
00524 }
00525 
00526 //______________________________________________________________________________
00527 void TEveCalo2D::BuildCellIdCache()
00528 {
00529    // Build lists of drawn cell IDs. See TEveCalo2DGL::DirecDraw().
00530 
00531    // clear old cache
00532    for (vBinCells_i it = fCellLists.begin(); it != fCellLists.end(); it++)
00533    {
00534       if (*it)
00535       {
00536          (*it)->clear();
00537          delete *it;
00538       }
00539    }
00540    fCellLists.clear();
00541    fCellLists.push_back(0);
00542 
00543    TEveProjection::EPType_e pt = fManager->GetProjection()->GetType();
00544    TEveCaloData::vCellId_t* clv; // ids per phi bin in r-phi projection else ids per eta bins in rho-z projection
00545 
00546    Bool_t isRPhi = (pt == TEveProjection::kPT_RPhi);
00547 
00548    const TAxis* axis = isRPhi ? fData->GetPhiBins() :  fData->GetEtaBins();
00549    Int_t nBins = axis->GetNbins();
00550 
00551    Float_t min, max;
00552    if (isRPhi)
00553    {
00554       min = GetPhiMin() - fData->GetEps();
00555       max = GetPhiMax() + fData->GetEps();
00556       for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
00557          clv = 0;
00558          if ( TEveUtil::IsU1IntervalOverlappingByMinMax
00559               (min, max, axis->GetBinLowEdge(ibin), axis->GetBinUpEdge(ibin)))
00560          {
00561             clv = new TEveCaloData::vCellId_t();
00562             fData->GetCellList(GetEta(), GetEtaRng(), axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), *clv);
00563             if (!clv->size()) {
00564                delete clv; clv = 0;
00565             }
00566          }
00567          fCellLists.push_back(clv);
00568       }
00569    }
00570    else
00571    {
00572       min = GetEtaMin() - fData->GetEps();
00573       max = GetEtaMax() + fData->GetEps();
00574       for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
00575          clv = 0;
00576          Float_t low = axis->GetBinLowEdge(ibin);
00577          Float_t up = axis->GetBinUpEdge(ibin) ;
00578          if (low >= min && up <= max)
00579          {
00580             clv = new TEveCaloData::vCellId_t();
00581             fData->GetCellList(axis->GetBinCenter(ibin), axis->GetBinWidth(ibin), fPhi, GetPhiRng(), *clv);
00582             if (!clv->size()) {
00583                delete clv; clv = 0;
00584             }
00585          }
00586          fCellLists.push_back(clv);
00587       }
00588    }
00589 
00590    // cache max bin sum for auto scale
00591    if (!fScaleAbs)
00592    {
00593       fMaxESumBin  = 0;
00594       fMaxEtSumBin = 0;
00595       Float_t sumE  = 0;
00596       Float_t sumEt = 0;
00597       TEveCaloData::CellData_t  cellData;
00598       for (Int_t ibin = 1; ibin <= nBins; ++ibin) {
00599          TEveCaloData::vCellId_t* cids = fCellLists[ibin];
00600          if (cids)
00601          {
00602             sumE = 0; sumEt = 0;
00603             for (TEveCaloData::vCellId_i it = cids->begin(); it != cids->end(); it++)
00604             {  
00605                fData->GetCellData(*it, cellData);
00606                sumE  += cellData.Value(kFALSE);
00607                sumEt += cellData.Value(kTRUE);
00608             }
00609             fMaxESumBin  = TMath::Max(fMaxESumBin,  sumE);
00610             fMaxEtSumBin = TMath::Max(fMaxEtSumBin, sumEt);  
00611          }
00612       }
00613       ComputeBBox();
00614    }
00615 
00616    fCellIdCacheOK= kTRUE;
00617 }
00618 
00619 //______________________________________________________________________________
00620 void TEveCalo2D::CellSelectionChanged()
00621 {
00622    // Sort slected cells in eta or phi bins for selection and highlight.
00623 
00624    CellSelectionChangedInternal(fData->GetCellsSelected(), fCellListsSelected);
00625    CellSelectionChangedInternal(fData->GetCellsHighlighted(), fCellListsHighlighted);
00626 }
00627 
00628 //______________________________________________________________________________
00629 void TEveCalo2D::CellSelectionChangedInternal(TEveCaloData::vCellId_t& inputCells, std::vector<TEveCaloData::vCellId_t*>& outputCellLists)
00630 {
00631    // Sort slected cells in eta or phi bins.
00632 
00633    Bool_t isRPhi = (fManager->GetProjection()->GetType() == TEveProjection::kPT_RPhi);
00634    const TAxis* axis = isRPhi ? fData->GetPhiBins() :  fData->GetEtaBins();
00635 
00636    // clear old cache
00637    for (vBinCells_i it = outputCellLists.begin(); it != outputCellLists.end(); it++)
00638    {
00639       if (*it)
00640       {
00641          (*it)->clear();
00642          delete *it;
00643       }
00644    }
00645    outputCellLists.clear();
00646    UInt_t nBins = axis->GetNbins();
00647    outputCellLists.resize(nBins+1);
00648    for (UInt_t b = 0; b <= nBins; ++b)
00649       outputCellLists[b] = 0;
00650 
00651    for(UInt_t bin = 1; bin <= nBins; ++bin)
00652    {
00653       TEveCaloData::vCellId_t* idsInBin = fCellLists[bin];
00654       if (!idsInBin)
00655          continue;
00656 
00657       for (TEveCaloData::vCellId_i i = idsInBin->begin(); i != idsInBin->end(); i++)
00658       { 
00659          for (TEveCaloData::vCellId_i j = inputCells.begin(); j != inputCells.end(); j++)
00660          {
00661             if( (*i).fTower == (*j).fTower && (*i).fSlice == (*j).fSlice)
00662             {
00663                if (!outputCellLists[bin])
00664                   outputCellLists[bin] = new TEveCaloData::vCellId_t();
00665 
00666                outputCellLists[bin]->push_back(TEveCaloData::CellId_t((*i).fTower, (*i).fSlice, (*i).fFraction));
00667             }
00668          }
00669       }
00670    }
00671 }
00672 
00673 //______________________________________________________________________________
00674 void TEveCalo2D::SetScaleAbs(Bool_t sa)
00675 {
00676    // Set absolute scale in projected calorimeter.
00677    
00678    TEveCaloViz::SetScaleAbs(sa);
00679    BuildCellIdCache();
00680 }
00681 
00682 //______________________________________________________________________________
00683 Float_t TEveCalo2D::GetValToHeight() const
00684 {
00685    // Virtual function of TEveCaloViz.
00686    // Get transformation factor from E/Et to height.
00687 
00688    AssertCellIdCache();
00689 
00690    if (fScaleAbs)
00691    {
00692       return fMaxTowerH/fMaxValAbs;
00693    }
00694    else
00695    {
00696       if (fData->Empty())
00697          return 1;
00698 
00699       if (fPlotEt)
00700          return fMaxTowerH/fMaxEtSumBin;
00701       else
00702          return fMaxTowerH/fMaxESumBin;
00703    }
00704 }
00705 
00706 //______________________________________________________________________________
00707 void TEveCalo2D::ComputeBBox()
00708 {
00709    // Fill bounding-box information of the base-class TAttBBox (virtual method).
00710    // If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
00711 
00712    BBoxZero();
00713 
00714    Float_t x, y, z;
00715    Float_t th = fMaxTowerH                                           ;
00716    Float_t r  = fBarrelRadius + th;
00717    Float_t ze = fEndCapPos + th;
00718 
00719    x = r,  y = 0, z = 0;
00720    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00721    BBoxCheckPoint(x, y, z);
00722    x = -r, y = 0, z = 0;
00723    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00724    BBoxCheckPoint(x, y, z);
00725 
00726    x = 0, y = 0, z = ze;
00727    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00728    BBoxCheckPoint(x, y, z);
00729    x = 0, y = 0, z = -ze;
00730    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00731    BBoxCheckPoint(x, y, z);
00732 
00733    x = 0, y = r,  z = 0;
00734    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00735    BBoxCheckPoint(x, y, z);
00736    x = 0, y = -r, z = 0;
00737    fManager->GetProjection()->ProjectPoint(x, y, z, fDepth);
00738    BBoxCheckPoint(x, y, z);
00739 }
00740 
00741 
00742 //==============================================================================
00743 // TEveCaloLego
00744 //==============================================================================
00745 
00746 //______________________________________________________________________________
00747 //
00748 // Visualization of calorimeter data as eta/phi histogram.
00749 
00750 ClassImp(TEveCaloLego);
00751 
00752 //______________________________________________________________________________
00753 TEveCaloLego::TEveCaloLego(TEveCaloData* d, const char* n, const char* t):
00754    TEveCaloViz(d, n, t),
00755 
00756    fFontColor(-1),
00757    fGridColor(-1),
00758    fPlaneColor(kRed-5),
00759    fPlaneTransparency(60),
00760 
00761    fNZSteps(6),
00762    fZAxisStep(0.f),
00763 
00764    fAutoRebin(kTRUE),
00765 
00766    fPixelsPerBin(12),
00767    fNormalizeRebin(kFALSE),
00768 
00769    fProjection(kAuto),
00770    f2DMode(kValSize),
00771    fBoxMode(kBack),
00772 
00773    fDrawHPlane(kFALSE),
00774    fHPlaneVal(0),
00775 
00776    fHasFixedHeightIn2DMode(kFALSE),
00777    fFixedHeightValIn2DMode(0.f),
00778 
00779    fDrawNumberCellPixels(18), // draw numbers on cell above 30 pixels
00780    fCellPixelFontSize(12) // size of cell fonts in pixels
00781 {
00782    // Constructor.
00783 
00784    fMaxTowerH = 1;
00785    SetElementNameTitle("TEveCaloLego", "TEveCaloLego");
00786 }
00787 
00788 //______________________________________________________________________________
00789 void TEveCaloLego::SetData(TEveCaloData* data)
00790 {
00791    TEveCaloViz::SetData(data);
00792 }
00793 
00794 //______________________________________________________________________________
00795 void TEveCaloLego::BuildCellIdCache()
00796 {
00797    // Build list of drawn cell IDs. For more information see TEveCaloLegoGL:DirectDraw().
00798 
00799    fCellList.clear();
00800 
00801    fData->GetCellList(GetEta(), GetEtaRng(), GetPhi(), GetPhiRng(), fCellList);
00802    fCellIdCacheOK = kTRUE;
00803 }
00804 
00805 //______________________________________________________________________________
00806 void TEveCaloLego::ComputeBBox()
00807 {
00808    // Fill bounding-box information of the base-class TAttBBox (virtual method).
00809    // If member 'TEveFrameBox* fFrame' is set, frame's corners are used as bbox.
00810 
00811 
00812    // fBBox = Float_t[6] X(min,max), Y(min,max), Z(min,max)
00813 
00814    BBoxZero();
00815 
00816    Float_t ex = 1.2; // 20% offset for axis labels
00817 
00818    Float_t a = 0.5*ex;
00819 
00820    fBBox[0] = -a;
00821    fBBox[1] =  a;
00822    fBBox[2] = -a;
00823    fBBox[3] =  a;
00824 
00825    // scaling is relative to shortest XY axis
00826    Double_t em, eM, pm, pM;
00827    fData->GetEtaLimits(em, eM);
00828    fData->GetPhiLimits(pm, pM);
00829    Double_t r = (eM-em)/(pM-pm);
00830    if (r<1)
00831    {
00832       fBBox[2] /= r;
00833       fBBox[3] /= r;
00834    }
00835    else
00836    {
00837       fBBox[0] *= r;
00838       fBBox[1] *= r;
00839    }
00840 
00841    fBBox[4] =  0;
00842    if (fScaleAbs && !fData->Empty())
00843       fBBox[5] = GetMaxVal()*GetValToHeight();
00844    else
00845       fBBox[5] = fMaxTowerH;
00846 }

Generated on Tue Jul 5 14:16:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1