Logo ROOT  
Reference Guide
calo_detail.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Calorimeter detailed view by using TEveCaloDataVec as data-source.
4/// Demonstrates how to plot calorimeter data with irregular bins.
5///
6/// \image html eve_calo_detail.png
7/// \macro_code
8///
9/// \author Alja Mrak-Tadel
10
11#include "calorimeters.C"
12
13TEveCaloDataVec* MakeVecData(Int_t ncells=0);
14
15void calo_detail()
16{
18
19 // data
20 auto data = MakeVecData(20);
21 data->IncDenyDestroy(); // don't delete if zero parent
22
23 // frames
25 auto packH = slot->MakePack();
26 packH->SetElementName("Projections");
27 packH->SetHorizontal();
28 packH->SetShowTitleBar(kFALSE);
29
30 slot = packH->NewSlot();
31 auto pack0 = slot->MakePack();
32 pack0->SetShowTitleBar(kFALSE);
33 auto slotLeftTop = pack0->NewSlot();
34 auto slotLeftBottom = pack0->NewSlot();
35
36 slot = packH->NewSlot();
37 auto pack1 = slot->MakePack();
38 pack1->SetShowTitleBar(kFALSE);
39 auto slotRightTop = pack1->NewSlot();
40 auto slotRightBottom = pack1->NewSlot();
41
42 // viewers ans scenes in second tab
43 Float_t maxH = 300;
44 TEveCalo3D* calo3d = MakeCalo3D(data, slotRightTop);
45 calo3d->SetMaxTowerH(maxH);
46
47 TEveCalo2D* calo2d;
48 calo2d = MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
49 calo2d->SetMaxTowerH(maxH);
50 calo2d = MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
51 calo2d->SetMaxTowerH(maxH);
52
53 TEveCaloLego* lego = MakeCaloLego(data, slotRightBottom);
54 lego->SetAutoRebin(kFALSE);
56
57 gEve->AddElement(lego);
59
62
63}
64
65//______________________________________________________________________________
66TEveCaloDataVec* MakeVecData(Int_t ncells)
67{
68 // Example how to fill data when bins can be irregular.
69 // If ncells = 0 (default) whole histogram is taken,
70 // otherwise just ncells cells around the maximum.
71
73 auto hf = TFile::Open(histFile, "CACHEREAD");
74 TH2F* h1 = (TH2F*)hf->Get("ecalLego");
75 TH2F* h2 = (TH2F*)hf->Get("hcalLego");
76
77 auto data = new TEveCaloDataVec(2);
78 data->RefSliceInfo(0).Setup("ECAL", 0.3, kRed);
79 data->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
80
81 auto ax = h1->GetXaxis();
82 auto ay = h1->GetYaxis();
83
84 Int_t xm = 1, xM = ax->GetNbins();
85 Int_t ym = 1, yM = ay->GetNbins();
86 if (ncells != 0)
87 {
88 Int_t cx, cy, cz;
89 h1->GetMaximumBin(cx, cy, cz);
90 xm = TMath::Max(xm, cx-ncells);
91 xM = TMath::Min(xM, cx+ncells);
92 ym = TMath::Max(ym, cy-ncells);
93 yM = TMath::Min(yM, cy+ncells);
94 }
95
96 // Take every second cell and set a random size.
97 for (Int_t i=xm; i<=xM; i+=2) {
98 for (Int_t j=ym; j<=yM; j+=2) {
99 if ( (i+j) % 3) {
100 data->AddTower(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i),
101 ay->GetBinLowEdge(j), ay->GetBinUpEdge(j));
102 data->FillSlice(0, h1->GetBinContent(i, j));
103 data->FillSlice(1, h2->GetBinContent(i, j));
104 } else {
105 data->AddTower(ax->GetBinLowEdge(i),
106 2 * ax->GetBinWidth(i) + ax->GetBinLowEdge(i),
107 ay->GetBinLowEdge(j),
108 2 * ay->GetBinWidth(j) + ay->GetBinLowEdge(j));
109 data->FillSlice(0, h2->GetBinContent(i, j));
110 data->FillSlice(1, h2->GetBinContent(i, j));
111 }
112 }
113 }
114
115 data->SetEtaBins(ax);
116 data->SetPhiBins(ay);
117 data->DataChanged();
118 return data;
119}
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
@ 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:323
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:3942
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ,...
Definition: TGLViewer.cxx:1792
@ 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:508
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:8036
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4907
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