Logo ROOT   6.07/09
Reference Guide
calorimeters.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Demonstrates usage of EVE calorimetry classes.
4 ///
5 /// \image html eve_calorimeters.png
6 /// \macro_code
7 ///
8 /// \author Alja Mrak-Tadel
9 
10 #include "TEveProjections.h"
11 
12 const char* histFile =
13  "http://amraktad.web.cern.ch/amraktad/cms_calo_hist.root";
14 
15 TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot);
16 TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot, TEveProjection::EPType_e t);
17 TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot);
18 TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot, TEveProjection::EPType_e t);
19 void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s);
20 void add_jet(TEveElement*, const char*, Float_t, Float_t, Float_t, Float_t);
21 
22 void calorimeters()
23 {
26 
27  // event data
29  TFile* hf = TFile::Open(histFile, "CACHEREAD");
30  TH2F* ecalHist = (TH2F*)hf->Get("ecalLego");
31  TH2F* hcalHist = (TH2F*)hf->Get("hcalLego");
32  TEveCaloDataHist* data = new TEveCaloDataHist();
33  data->AddHistogram(ecalHist);
34  data->RefSliceInfo(0).Setup("ECAL", 0.3, kBlue);
35  data->AddHistogram(hcalHist);
36  data->RefSliceInfo(1).Setup("HCAL", 0.1, kRed);
37  data->GetEtaBins()->SetTitleFont(120);
38  data->GetEtaBins()->SetTitle("h");
39  data->GetPhiBins()->SetTitleFont(120);
40  data->GetPhiBins()->SetTitle("f");
41  data->IncDenyDestroy();
42  gEve->AddToListTree(data, kFALSE);
43 
44 
45  // first tab
46  TEveCaloLego* lego = MakeCaloLego(data, 0);
47 
48  //
49  // second tab
50  //
51 
52  // frames
53  TEveWindowSlot* slot =
55  TEveWindowPack* packH = slot->MakePack();
56  packH->SetElementName("Projections");
57  packH->SetHorizontal();
58  packH->SetShowTitleBar(kFALSE);
59 
60  slot = packH->NewSlot();
61  TEveWindowPack* pack0 = slot->MakePack();
62  pack0->SetShowTitleBar(kFALSE);
63  TEveWindowSlot* slotLeftTop = pack0->NewSlot();
64  TEveWindowSlot* slotLeftBottom = pack0->NewSlot();
65 
66  slot = packH->NewSlot();
67  TEveWindowPack* pack1 = slot->MakePack();
68  pack1->SetShowTitleBar(kFALSE);
69  TEveWindowSlot* slotRightTop = pack1->NewSlot();
70  TEveWindowSlot* slotRightBottom = pack1->NewSlot();
71 
72  // viewers ans scenes in second tab
73  TEveCalo3D* calo3d = MakeCalo3D(data, slotRightTop);
74  MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
75  MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
76  lego = MakeCaloLego(data, slotRightBottom);
77 
78 
81 }
82 
83 //______________________________________________________________________________
84 TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot)
85 {
86  // Eta-phi lego view.
87 
88  TEveViewer* v;
89  TEveScene* s;
90  if (slot)
91  {
92  TEveViewer* v; TEveScene* s;
93  MakeViewerScene(slot, v, s);
94  } else {
95  v = gEve->GetDefaultViewer();
96  s = gEve->GetEventScene();
97  }
98  v->SetElementName("Viewer - Lego");
99  s->SetElementName("Scene - Lego");
100 
101  TEveCaloLego* lego = new TEveCaloLego(data);
102  s->AddElement(lego);
103 
104  // By the default lego extends is (1x1x1). Resize it to put in 'natural'
105  // coordinates, so that y extend in 2*Pi and set height of lego two times
106  // smaller than y extend to have better view in 3D perspective.
107  lego->InitMainTrans();
109 
110  // draws scales and axis on borders of window
111  TGLViewer* glv = v->GetGLViewer();
112  TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
113  glv->AddOverlayElement(overlay);
114  overlay->SetCaloLego(lego);
115 
116  // set event handler to move from perspective to orthographic view.
118  glv->SetEventHandler
119  (new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
120  gEve->AddToListTree(lego, kTRUE);
121 
122  return lego;
123 }
124 
125 //______________________________________________________________________________
126 TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot)
127 {
128  // 3D catersian view.
129 
130  TEveViewer* v; TEveScene* s;
131  MakeViewerScene(slot, v, s);
132  v->SetElementName("Viewer - 3D");
133  s->SetElementName("Scene - 3D");
134 
135  TEveCalo3D* calo3d = new TEveCalo3D(data);
136  calo3d->SetBarrelRadius(129.00);
137  calo3d->SetEndCapPos(268.36);
138  s->AddElement(calo3d);
139 
140  add_jet(calo3d, "JetCone Lojz", 1.4, 1.0, 0.4, 0.2);
141  add_jet(calo3d, "JetCone Mici", -2.0, -2.1, 0.2, 0.4);
142 
143  return calo3d;
144 }
145 
146 //______________________________________________________________________________
147 TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot,
149 {
150  // Projected calorimeter.
151 
152  TEveViewer* v; TEveScene* s;
153  MakeViewerScene(slot, v, s);
154  v->SetElementName("Viewer - 2D");
155  s->SetElementName("Scene - 2D");
156 
158  mng->SetProjection(t);
159 
160  TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
161  s->AddElement(axes);
162  TEveCalo2D* calo2d = (TEveCalo2D*) mng->ImportElements(calo3d);
163  s->AddElement(calo2d);
164 
166 
167  gEve->AddToListTree(mng, kTRUE);
168  gEve->AddToListTree(calo2d, kTRUE);
169 
170  return calo2d;
171 }
172 
173 //______________________________________________________________________________
174 void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s)
175 {
176  // Create a scene and a viewer in the given slot.
177 
178  v = new TEveViewer("Viewer");
180  slot->ReplaceWindow(v);
181  gEve->GetViewers()->AddElement(v);
182  s = gEve->SpawnNewScene("Scene");
183  v->AddScene(s);
184 }
185 
186 //______________________________________________________________________________
187 void add_jet(TEveElement* parent, const char* name,
188  Float_t eta, Float_t phi,
189  Float_t deta, Float_t dphi)
190 {
191  TEveJetCone* jet = new TEveJetCone(name, name);
192  jet->SetMainTransparency(60);
193  jet->SetLineColor(kRed);
194  jet->SetCylinder(129 - 10, 268.36 - 10);
195  jet->AddEllipticCone(eta, phi, deta, dphi);
196  jet->SetPickable(kTRUE);
198  parent->AddElement(jet);
199 }
virtual TEveWindowSlot * NewSlot()
Create a new frame-slot at the last position of the pack.
TEveViewerList * GetViewers() const
Definition: TEveManager.h:145
virtual TAxis * GetPhiBins() const
Definition: TEveCaloData.h:221
virtual TEveWindowSlot * NewSlot()
Definition: TEveWindow.h:242
Encapsulates TGPack into an eve-window.
Definition: TEveWindow.h:360
A central manager for calorimeter event data.
Definition: TEveCaloData.h:26
A base class of TGLEventHandler.
virtual void SetHighlightFrame(Bool_t f)
Definition: TEveShape.h:63
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
Eve representation of TGLScene.
Definition: TEveScene.h:26
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
Definition: Rtypes.h:61
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: TEveTrans.cxx:688
void SetPickable(Bool_t p)
Definition: TEveElement.h:340
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
Definition: TGLViewer.cxx:2270
virtual void SetLineColor(Color_t c)
Definition: TEveShape.h:60
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
void IncDenyDestroy()
Increases the deny-destroy count of the element.
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given...
Definition: TEveJetCone.h:23
Description of TEveWindowSlot.
Definition: TEveWindow.h:301
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition: TAttAxis.cxx:290
const Bool_t kFALSE
Definition: Rtypes.h:92
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
Axes for non-linear projections.
Int_t AddEllipticCone(Float_t eta, Float_t phi, Float_t reta, Float_t rphi, Float_t length=0)
Add jet cone.
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
void SetBarrelRadius(Float_t r)
Definition: TEveCalo.h:100
TGLViewer * GetGLViewer() const
Definition: TEveViewer.h:51
Visualization of a calorimeter event data in 2D.
Definition: TEveCalo.h:199
virtual TEveElement * ImportElements(TEveElement *el, TEveElement *ext_list=0)
Recursively import elements and apply projection to the newly imported objects.
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
Definition: TEveWindow.cxx:819
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Double_t TwoPi()
Definition: TMath.h:45
virtual void SetElementName(const char *name)
Virtual function for setting of name of an element.
Definition: TEveElement.h:484
Manager class for steering of projections and managing projected objects.
void SetCaloLego(TEveCaloLego *c)
Int_t AddHistogram(TH2F *hist)
Add new slice to calo tower.
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
TEveGedEditor * GetEditor() const
Returns main object editor.
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
TEveViewer * GetDefaultViewer() const
Returns the default viewer - the first one in the fViewers list.
SVector< double, 2 > v
Definition: Dict.h:5
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
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
virtual void AddElement(TEveElement *el)
Add el to the list of children.
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
Double_t Pi()
Definition: TMath.h:44
Visualization of calorimeter data as eta/phi histogram.
Definition: TEveCalo.h:249
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
TEveWindowPack * MakePack()
A pack is created in place of this window-slot.
TEveScene * GetEventScene() const
Definition: TEveManager.h:148
TEveBrowser * GetBrowser() const
Definition: TEveManager.h:137
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
void SetProjection(TEveProjection::EPType_e type)
Set projection type and distortion.
virtual TAxis * GetEtaBins() const
Definition: TEveCaloData.h:218
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
void SetEndCapPos(Float_t z)
Definition: TEveCalo.h:104
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
virtual void AddElement(TEveElement *el)
Call base-class implementation.
Definition: TEveViewer.cxx:358
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
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 SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
GL-overlay control GUI for TEveCaloLego.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
char name[80]
Definition: TGX11.cxx:109
Eve representation of TGLViewer.
Definition: TEveViewer.h:30
void SetCylinder(Float_t r, Float_t z)
Definition: TEveJetCone.h:55
A central manager for calorimeter data of an event written in TH2F.
Definition: TEveCaloData.h:297
TGLSAViewer * SpawnGLViewer(TGedEditor *ged=0, Bool_t stereo=kFALSE, Bool_t quad_buf=kTRUE)
Spawn new GLViewer and adopt it.
Definition: TEveViewer.cxx:155
TGLWidget * GetGLWidget()
Definition: TGLViewer.h:223
virtual void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
Definition: TSystem.cxx:598
virtual void AddScene(TEveScene *scene)
Add &#39;scene&#39; to the list of scenes.
Definition: TEveViewer.cxx:261