Logo ROOT   6.07/09
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 
13 TEveCaloDataVec* MakeVecData(Int_t ncells=0);
14 
15 void calo_detail()
16 {
18 
19  // data
20  TEveCaloDataVec* data = MakeVecData(20);
21  data->IncDenyDestroy(); // don't delete if zero parent
22 
23  // frames
24  TEveWindowSlot* slot =
26  TEveWindowPack* packH = slot->MakePack();
27  packH->SetElementName("Projections");
28  packH->SetHorizontal();
29  packH->SetShowTitleBar(kFALSE);
30 
31  slot = packH->NewSlot();
32  TEveWindowPack* pack0 = slot->MakePack();
33  pack0->SetShowTitleBar(kFALSE);
34  TEveWindowSlot* slotLeftTop = pack0->NewSlot();
35  TEveWindowSlot* slotLeftBottom = pack0->NewSlot();
36 
37  slot = packH->NewSlot();
38  TEveWindowPack* pack1 = slot->MakePack();
39  pack1->SetShowTitleBar(kFALSE);
40  TEveWindowSlot* slotRightTop = pack1->NewSlot();
41  TEveWindowSlot* slotRightBottom = pack1->NewSlot();
42 
43  // viewers ans scenes in second tab
44  Float_t maxH = 300;
45  TEveCalo3D* calo3d = MakeCalo3D(data, slotRightTop);
46  calo3d->SetMaxTowerH(maxH);
47 
48  TEveCalo2D* calo2d;
49  calo2d = MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
50  calo2d->SetMaxTowerH(maxH);
51  calo2d = MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
52  calo2d->SetMaxTowerH(maxH);
53 
54  TEveCaloLego* lego = MakeCaloLego(data, slotRightBottom);
55  lego->SetAutoRebin(kFALSE);
57 
58  gEve->AddElement(lego);
60 
63 
64 }
65 
66 //______________________________________________________________________________
67 TEveCaloDataVec* MakeVecData(Int_t ncells)
68 {
69  // Example how to fill data when bins can be iregular.
70  // If ncells = 0 (default) whole histogram is taken,
71  // otherwise just ncells cells around the maximum.
72 
74  TFile* hf = TFile::Open(histFile, "CACHEREAD");
75  TH2F* h1 = (TH2F*)hf->Get("ecalLego");
76  TH2F* h2 = (TH2F*)hf->Get("hcalLego");
77 
78  TEveCaloDataVec* data = new TEveCaloDataVec(2);
79  data->RefSliceInfo(0).Setup("ECAL", 0.3, kRed);
80  data->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
81 
82  TAxis *ax = h1->GetXaxis();
83  TAxis *ay = h1->GetYaxis();
84 
85  Int_t xm = 1, xM = ax->GetNbins();
86  Int_t ym = 1, yM = ay->GetNbins();
87  if (ncells != 0)
88  {
89  Int_t cx, cy, cz;
90  h1->GetMaximumBin(cx, cy, cz);
91  xm = TMath::Max(xm, cx-ncells);
92  xM = TMath::Min(xM, cx+ncells);
93  ym = TMath::Max(ym, cy-ncells);
94  yM = TMath::Min(yM, cy+ncells);
95  }
96 
97  // Take every second cell and set a random size.
98  for(Int_t i=xm; i<=xM; i+=2)
99  {
100  for(Int_t j=ym; j<=yM; j+=2)
101  {
102  if ( (i+j) % 3)
103  {
104  data->AddTower(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i),
105  ay->GetBinLowEdge(j), ay->GetBinUpEdge(j));
106  data->FillSlice(0, h1->GetBinContent(i, j));
107  data->FillSlice(1, h2->GetBinContent(i, j));
108  }
109  else
110  {
111  data->AddTower(ax->GetBinLowEdge(i),
112  2 * ax->GetBinWidth(i) + ax->GetBinLowEdge(i),
113  ay->GetBinLowEdge(j),
114  2 * ay->GetBinWidth(j) + ay->GetBinLowEdge(j));
115  data->FillSlice(0, h2->GetBinContent(i, j));
116  data->FillSlice(1, h2->GetBinContent(i, j));
117  }
118  }
119  }
120 
121  data->SetEtaBins(ax);
122  data->SetPhiBins(ay);
123  data->DataChanged();
124  return data;
125 }
virtual TEveWindowSlot * NewSlot()
Create a new frame-slot at the last position of the pack.
virtual TEveWindowSlot * NewSlot()
Definition: TEveWindow.h:242
Encapsulates TGPack into an eve-window.
Definition: TEveWindow.h:360
SliceInfo_t & RefSliceInfo(Int_t s)
Definition: TEveCaloData.h:203
void Setup(const char *name, Float_t threshold, Color_t col, Char_t transp=101)
Definition: TEveCaloData.h:41
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.
float Float_t
Definition: RtypesCore.h:53
void SetMaxTowerH(Float_t x)
Definition: TEveCalo.h:111
virtual Int_t GetMaximumBin() const
Return location of bin with maximum value in the range.
Definition: TH1.cxx:7651
Definition: Rtypes.h:61
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:504
void IncDenyDestroy()
Increases the deny-destroy count of the element.
Demonstrates usage of EVE calorimetry classes.
Calo data for universal cell geometry.
Definition: TEveCaloData.h:239
Description of TEveWindowSlot.
Definition: TEveWindow.h:301
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
void FillSlice(Int_t slice, Float_t value)
Fill given slice in the current tower.
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition: TAxis.cxx:526
void Set2DMode(E2DMode_e p)
Definition: TEveCalo.h:327
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3871
Visualization of a calorimeter event data in 2D.
Definition: TEveCalo.h:199
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TH1F * h1
Definition: legend1.C:5
virtual void SetElementName(const char *name)
Virtual function for setting of name of an element.
Definition: TEveElement.h:484
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH2.h:90
Class to manage histogram axis.
Definition: TAxis.h:36
Int_t GetNbins() const
Definition: TAxis.h:127
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:514
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
tomato 2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:255
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 * GetYaxis()
Definition: TH1.h:325
Visualization of calorimeter data as eta/phi histogram.
Definition: TEveCalo.h:249
Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
Add tower within eta/phi range.
void FullRedraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Perform 3D redraw of all scenes and viewers.
TEveWindowPack * MakePack()
A pack is created in place of this window-slot.
virtual void DataChanged()
Update limits and notify data users.
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
void SetCurrentCamera(ECameraType camera)
Set current active camera - &#39;cameraType&#39; one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1786
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition: TFile.cxx:4391
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
void SetAutoRebin(Bool_t s)
Definition: TEveCalo.h:319
Definition: Rtypes.h:61
Visualization of a calorimeter event data in 3D.
Definition: TEveCalo.h:156
void SetShowTitleBar(Bool_t x)
Set display state of the title-bar.
Definition: TEveWindow.cxx:898
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetEtaBins(TAxis *ax)
Definition: TEveCaloData.h:219
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
virtual void SetPhiBins(TAxis *ax)
Definition: TEveCaloData.h:222
TAxis * GetXaxis()
Definition: TH1.h:324