ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  gStyle->SetPalette(1, 0);
102  TEveCaloLego* lego = new TEveCaloLego(data);
103  s->AddElement(lego);
104 
105  // By the default lego extends is (1x1x1). Resize it to put in 'natural'
106  // coordinates, so that y extend in 2*Pi and set height of lego two times
107  // smaller than y extend to have better view in 3D perspective.
108  lego->InitMainTrans();
110 
111  // draws scales and axis on borders of window
112  TGLViewer* glv = v->GetGLViewer();
113  TEveCaloLegoOverlay* overlay = new TEveCaloLegoOverlay();
114  glv->AddOverlayElement(overlay);
115  overlay->SetCaloLego(lego);
116 
117  // set event handler to move from perspective to orthographic view.
119  glv->SetEventHandler
120  (new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
121  gEve->AddToListTree(lego, kTRUE);
122 
123  return lego;
124 }
125 
126 //______________________________________________________________________________
127 TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot)
128 {
129  // 3D catersian view.
130 
131  TEveViewer* v; TEveScene* s;
132  MakeViewerScene(slot, v, s);
133  v->SetElementName("Viewer - 3D");
134  s->SetElementName("Scene - 3D");
135 
136  TEveCalo3D* calo3d = new TEveCalo3D(data);
137  calo3d->SetBarrelRadius(129.00);
138  calo3d->SetEndCapPos(268.36);
139  s->AddElement(calo3d);
140 
141  add_jet(calo3d, "JetCone Lojz", 1.4, 1.0, 0.4, 0.2);
142  add_jet(calo3d, "JetCone Mici", -2.0, -2.1, 0.2, 0.4);
143 
144  return calo3d;
145 }
146 
147 //______________________________________________________________________________
148 TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot,
150 {
151  // Projected calorimeter.
152 
153  TEveViewer* v; TEveScene* s;
154  MakeViewerScene(slot, v, s);
155  v->SetElementName("Viewer - 2D");
156  s->SetElementName("Scene - 2D");
157 
159  mng->SetProjection(t);
160 
161  TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
162  s->AddElement(axes);
163  TEveCalo2D* calo2d = (TEveCalo2D*) mng->ImportElements(calo3d);
164  s->AddElement(calo2d);
165 
167 
168  gEve->AddToListTree(mng, kTRUE);
169  gEve->AddToListTree(calo2d, kTRUE);
170 
171  return calo2d;
172 }
173 
174 //______________________________________________________________________________
175 void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s)
176 {
177  // Create a scene and a viewer in the given slot.
178 
179  v = new TEveViewer("Viewer");
181  slot->ReplaceWindow(v);
182  gEve->GetViewers()->AddElement(v);
183  s = gEve->SpawnNewScene("Scene");
184  v->AddScene(s);
185 }
186 
187 //______________________________________________________________________________
188 void add_jet(TEveElement* parent, const char* name,
189  Float_t eta, Float_t phi,
190  Float_t deta, Float_t dphi)
191 {
192  TEveJetCone* jet = new TEveJetCone(name, name);
193  jet->SetMainTransparency(60);
194  jet->SetLineColor(kRed);
195  jet->SetCylinder(129 - 10, 268.36 - 10);
196  jet->AddEllipticCone(eta, phi, deta, dphi);
197  jet->SetPickable(kTRUE);
199  parent->AddElement(jet);
200 }
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
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
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:45
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
Definition: TGLViewer.cxx:2263
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:273
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:3851
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:545
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
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
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.
void lego()
Definition: lego.C:4
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 - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1779
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:4371
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="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
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
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445
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:597
virtual void AddScene(TEveScene *scene)
Add 'scene' to the list of scenes.
Definition: TEveViewer.cxx:261