Logo ROOT  
Reference Guide
calo_detail.C File Reference

Detailed Description

Calorimeter detailed view by using TEveCaloDataVec as data-source.

Demonstrates how to plot calorimeter data with irregular bins.

#include "calorimeters.C"
TEveCaloDataVec* MakeVecData(Int_t ncells=0);
void calo_detail()
{
// data
auto data = MakeVecData(20);
data->IncDenyDestroy(); // don't delete if zero parent
// frames
auto packH = slot->MakePack();
packH->SetElementName("Projections");
packH->SetHorizontal();
packH->SetShowTitleBar(kFALSE);
slot = packH->NewSlot();
auto pack0 = slot->MakePack();
pack0->SetShowTitleBar(kFALSE);
auto slotLeftTop = pack0->NewSlot();
auto slotLeftBottom = pack0->NewSlot();
slot = packH->NewSlot();
auto pack1 = slot->MakePack();
pack1->SetShowTitleBar(kFALSE);
auto slotRightTop = pack1->NewSlot();
auto 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);
gEve->AddElement(lego);
}
//______________________________________________________________________________
TEveCaloDataVec* MakeVecData(Int_t ncells)
{
// Example how to fill data when bins can be irregular.
// If ncells = 0 (default) whole histogram is taken,
// otherwise just ncells cells around the maximum.
auto hf = TFile::Open(histFile, "CACHEREAD");
TH2F* h1 = (TH2F*)hf->Get("ecalLego");
TH2F* h2 = (TH2F*)hf->Get("hcalLego");
auto data = new TEveCaloDataVec(2);
data->RefSliceInfo(0).Setup("ECAL", 0.3, kRed);
data->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
auto ax = h1->GetXaxis();
auto 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;
}
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
@ kRed
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
Demonstrates usage of EVE calorimetry classes.
Int_t GetNbins() const
Definition: TAxis.h:121
Visualization of a calorimeter event data in 2D.
Definition: TEveCalo.h:201
Visualization of a calorimeter event data in 3D.
Definition: TEveCalo.h:157
Calo data for universal cell geometry.
Definition: TEveCaloData.h:240
Visualization of calorimeter data as eta/phi histogram.
Definition: TEveCalo.h:250
void Set2DMode(E2DMode_e p)
Definition: TEveCalo.h:327
void SetAutoRebin(Bool_t s)
Definition: TEveCalo.h:319
@ kValSizeOutline
Definition: TEveCalo.h:256
void SetMaxTowerH(Float_t x)
Definition: TEveCalo.h:111
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=0)
Create a new tab in a given tab-widget and populate it with a default window-slot.
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition: TFile.h:319
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3923
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ,...
Definition: TGLViewer.cxx:1794
@ kCameraPerspXOY
Definition: TGLViewer.h:63
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition: TGTab.cxx:507
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
TAxis * GetYaxis()
Definition: TH1.h:317
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
Definition: TH1.cxx:8024
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4899
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH2.h:88
TGTab * GetTabRight() const
Definition: TRootBrowser.h:141
TH1F * h1
Definition: legend1.C:5
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Author
Alja Mrak-Tadel

Definition in file calo_detail.C.