From $ROOTSYS/tutorials/eve/calo_detail.C

// @(#)root/eve:$Id$
// Author: Alja Mrak-Tadel

// Calorimeter detailed view by using TEveCaloDataVec as data-source.
// Demonstrantes how to plot calorimiter data with irregular bins.

#include "calorimeters.C"

TEveCaloDataVec* MakeVecData(Int_t ncells=0);

void calo_detail()
{
   TEveManager::Create();

   // data
   TEveCaloDataVec* data = MakeVecData(20);
   data->IncDenyDestroy(); // don't delete if zero parent

   // frames
   TEveWindowSlot* slot =
      TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
   TEveWindowPack* packH = slot->MakePack();
   packH->SetElementName("Projections");
   packH->SetHorizontal();
   packH->SetShowTitleBar(kFALSE);

   slot = packH->NewSlot();
   TEveWindowPack* pack0 = slot->MakePack();
   pack0->SetShowTitleBar(kFALSE);
   TEveWindowSlot*  slotLeftTop   = pack0->NewSlot();
   TEveWindowSlot* slotLeftBottom = pack0->NewSlot();

   slot = packH->NewSlot();
   TEveWindowPack* pack1 = slot->MakePack();
   pack1->SetShowTitleBar(kFALSE);
   TEveWindowSlot* slotRightTop    = pack1->NewSlot();
   TEveWindowSlot* slotRightBottom = pack1->NewSlot();

   // viewers ans scenes in second tab
   Float_t maxH = 300;
   TEveCalo3D* calo3d = MakeCalo3D(data, slotRightTop);
   calo3d->SetMaxTowerH(maxH);

   TEveCalo2D* calo2d;
   calo2d = MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
   calo2d->SetMaxTowerH(maxH);
   calo2d = MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
   calo2d->SetMaxTowerH(maxH);

   TEveCaloLego* lego = MakeCaloLego(data, slotRightBottom);
   lego->SetAutoRebin(kFALSE);
   lego->Set2DMode(TEveCaloLego::kValSizeOutline);

   gEve->AddElement(lego);
   gEve->GetDefaultGLViewer()->SetCurrentCamera(TGLViewer::kCameraPerspXOY);

   gEve->GetBrowser()->GetTabRight()->SetTab(1);
   gEve->FullRedraw3D(kTRUE);

}

//______________________________________________________________________________
TEveCaloDataVec* MakeVecData(Int_t ncells)
{
   // Example how to fill data when bins can be iregular.
   // If ncells = 0 (default) whole histogram is taken,
   // otherwise just ncells cells around the maximum.

   TFile::SetCacheFileDir(".");
   TFile* hf = TFile::Open(histFile, "CACHEREAD");
   TH2F* h1 = (TH2F*)hf->Get("ecalLego");
   TH2F* h2 = (TH2F*)hf->Get("hcalLego");

   TEveCaloDataVec* data = new TEveCaloDataVec(2);
   data->RefSliceInfo(0).Setup("ECAL", 0.3, kRed);
   data->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);

   TAxis *ax =  h1->GetXaxis();
   TAxis *ay =  h1->GetYaxis();

   Int_t xm = 1, xM = ax->GetNbins();
   Int_t ym = 1, yM = ay->GetNbins();
   if (ncells != 0)
   {
      Int_t cx, cy, cz;
      h1->GetMaximumBin(cx, cy, cz);
      xm = TMath::Max(xm, cx-ncells);
      xM = TMath::Min(xM, cx+ncells);
      ym = TMath::Max(ym, cy-ncells);
      yM = TMath::Min(yM, cy+ncells);
   }

   // Take every second cell and set a random size.
   for(Int_t i=xm; i<=xM; i+=2)
   {
      for(Int_t j=ym; j<=yM; j+=2)
      {
         if ( (i+j) % 3)
         {
            data->AddTower(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i),
                           ay->GetBinLowEdge(j), ay->GetBinUpEdge(j));
            data->FillSlice(0, h1->GetBinContent(i, j));
            data->FillSlice(1, h2->GetBinContent(i, j));
         }
         else
         {
            data->AddTower(ax->GetBinLowEdge(i),
                           2 * ax->GetBinWidth(i) + ax->GetBinLowEdge(i),
                           ay->GetBinLowEdge(j),
                           2 * ay->GetBinWidth(j) + ay->GetBinLowEdge(j));
            data->FillSlice(0, h2->GetBinContent(i, j));
            data->FillSlice(1, h2->GetBinContent(i, j));
         }
      }
   }

   data->SetEtaBins(ax);
   data->SetPhiBins(ay);
   data->DataChanged();
   return data;
}
 calo_detail.C:1
 calo_detail.C:2
 calo_detail.C:3
 calo_detail.C:4
 calo_detail.C:5
 calo_detail.C:6
 calo_detail.C:7
 calo_detail.C:8
 calo_detail.C:9
 calo_detail.C:10
 calo_detail.C:11
 calo_detail.C:12
 calo_detail.C:13
 calo_detail.C:14
 calo_detail.C:15
 calo_detail.C:16
 calo_detail.C:17
 calo_detail.C:18
 calo_detail.C:19
 calo_detail.C:20
 calo_detail.C:21
 calo_detail.C:22
 calo_detail.C:23
 calo_detail.C:24
 calo_detail.C:25
 calo_detail.C:26
 calo_detail.C:27
 calo_detail.C:28
 calo_detail.C:29
 calo_detail.C:30
 calo_detail.C:31
 calo_detail.C:32
 calo_detail.C:33
 calo_detail.C:34
 calo_detail.C:35
 calo_detail.C:36
 calo_detail.C:37
 calo_detail.C:38
 calo_detail.C:39
 calo_detail.C:40
 calo_detail.C:41
 calo_detail.C:42
 calo_detail.C:43
 calo_detail.C:44
 calo_detail.C:45
 calo_detail.C:46
 calo_detail.C:47
 calo_detail.C:48
 calo_detail.C:49
 calo_detail.C:50
 calo_detail.C:51
 calo_detail.C:52
 calo_detail.C:53
 calo_detail.C:54
 calo_detail.C:55
 calo_detail.C:56
 calo_detail.C:57
 calo_detail.C:58
 calo_detail.C:59
 calo_detail.C:60
 calo_detail.C:61
 calo_detail.C:62
 calo_detail.C:63
 calo_detail.C:64
 calo_detail.C:65
 calo_detail.C:66
 calo_detail.C:67
 calo_detail.C:68
 calo_detail.C:69
 calo_detail.C:70
 calo_detail.C:71
 calo_detail.C:72
 calo_detail.C:73
 calo_detail.C:74
 calo_detail.C:75
 calo_detail.C:76
 calo_detail.C:77
 calo_detail.C:78
 calo_detail.C:79
 calo_detail.C:80
 calo_detail.C:81
 calo_detail.C:82
 calo_detail.C:83
 calo_detail.C:84
 calo_detail.C:85
 calo_detail.C:86
 calo_detail.C:87
 calo_detail.C:88
 calo_detail.C:89
 calo_detail.C:90
 calo_detail.C:91
 calo_detail.C:92
 calo_detail.C:93
 calo_detail.C:94
 calo_detail.C:95
 calo_detail.C:96
 calo_detail.C:97
 calo_detail.C:98
 calo_detail.C:99
 calo_detail.C:100
 calo_detail.C:101
 calo_detail.C:102
 calo_detail.C:103
 calo_detail.C:104
 calo_detail.C:105
 calo_detail.C:106
 calo_detail.C:107
 calo_detail.C:108
 calo_detail.C:109
 calo_detail.C:110
 calo_detail.C:111
 calo_detail.C:112
 calo_detail.C:113
 calo_detail.C:114
 calo_detail.C:115
 calo_detail.C:116
 calo_detail.C:117
 calo_detail.C:118
 calo_detail.C:119
 calo_detail.C:120
 calo_detail.C:121
 calo_detail.C:122