Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TSystem.h"
12#include "TEveCalo.h"
13#include "TEveWindow.h"
14#include "TEveManager.h"
15#include "TEveBrowser.h"
16#include "TEveProjectionAxes.h"
17#include "TEveScene.h"
18#include "TEveViewer.h"
19#include "TEveTrans.h"
20#include "TEveCaloLegoOverlay.h"
22#include "TEveGedEditor.h"
23#include "TEveJetCone.h"
24
25#include "TGLWidget.h"
26#include "TGLViewer.h"
27#include "TGTab.h"
28
29#include "TFile.h"
30#include "TAxis.h"
31
32
33const char* histFile =
34 "http://amraktad.web.cern.ch/amraktad/cms_calo_hist.root";
35
36TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot);
38TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot);
40void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s);
41void add_jet(TEveElement*, const char*, Float_t, Float_t, Float_t, Float_t);
42
43void calorimeters()
44{
45 // gSystem->IgnoreSignal(kSigSegmentationViolation, true);
47
48 // event data
50 auto hf = TFile::Open(histFile, "CACHEREAD");
51 auto ecalHist = (TH2F*)hf->Get("ecalLego");
52 auto hcalHist = (TH2F*)hf->Get("hcalLego");
53 auto data = new TEveCaloDataHist();
54 data->AddHistogram(ecalHist);
55 data->RefSliceInfo(0).Setup("ECAL", 0.3, kBlue);
56 data->AddHistogram(hcalHist);
57 data->RefSliceInfo(1).Setup("HCAL", 0.1, kRed);
58 data->GetEtaBins()->SetTitleFont(120);
59 data->GetEtaBins()->SetTitle("h");
60 data->GetPhiBins()->SetTitleFont(120);
61 data->GetPhiBins()->SetTitle("f");
62 data->IncDenyDestroy();
64
65
66 // first tab
67 auto lego = MakeCaloLego(data, nullptr);
68
69 //
70 // second tab
71 //
72
73 // frames
75 auto packH = slot->MakePack();
76 packH->SetElementName("Projections");
77 packH->SetHorizontal();
78 packH->SetShowTitleBar(kFALSE);
79
80 slot = packH->NewSlot();
81 auto pack0 = slot->MakePack();
82 pack0->SetShowTitleBar(kFALSE);
83 auto slotLeftTop = pack0->NewSlot();
84 auto slotLeftBottom = pack0->NewSlot();
85
86 slot = packH->NewSlot();
87 auto pack1 = slot->MakePack();
88 pack1->SetShowTitleBar(kFALSE);
89 auto slotRightTop = pack1->NewSlot();
90 auto slotRightBottom = pack1->NewSlot();
91
92 // viewers ans scenes in second tab
93 auto calo3d = MakeCalo3D(data, slotRightTop);
94 MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
95 MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
96 lego = MakeCaloLego(data, slotRightBottom);
97
98
101}
102
103//______________________________________________________________________________
104TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot)
105{
106 // Eta-phi lego view.
107
108 TEveViewer* v;
109 TEveScene* s;
110 if (slot) {
111 MakeViewerScene(slot, v, s);
112 } else {
114 s = gEve->GetEventScene();
115 }
116 v->SetElementName("Viewer - Lego");
117 s->SetElementName("Scene - Lego");
118
119 auto lego = new TEveCaloLego(data);
120 s->AddElement(lego);
121
122 // By the default lego extends is (1x1x1). Resize it to put in 'natural'
123 // coordinates, so that y extend in 2*Pi and set height of lego two times
124 // smaller than y extend to have better view in 3D perspective.
125 lego->InitMainTrans();
126 lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
127
128 // draws scales and axis on borders of window
129 auto glv = v->GetGLViewer();
131 glv->AddOverlayElement(overlay);
132 overlay->SetCaloLego(lego);
133
134 // set event handler to move from perspective to orthographic view.
135 glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
136 glv->SetEventHandler
137 (new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
139
140 return lego;
141}
142
143//______________________________________________________________________________
144TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot)
145{
146 // 3D cartesian view.
147
149 MakeViewerScene(slot, v, s);
150 v->SetElementName("Viewer - 3D");
151 s->SetElementName("Scene - 3D");
152
153 auto calo3d = new TEveCalo3D(data);
154 calo3d->SetBarrelRadius(129.00);
155 calo3d->SetEndCapPos(268.36);
156 s->AddElement(calo3d);
157
158 add_jet(calo3d, "JetCone Lojz", 1.4, 1.0, 0.4, 0.2);
159 add_jet(calo3d, "JetCone Mici", -2.0, -2.1, 0.2, 0.4);
160
161 return calo3d;
162}
163
164//______________________________________________________________________________
165TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot,
167{
168 // Projected calorimeter.
169
171 MakeViewerScene(slot, v, s);
172 v->SetElementName("Viewer - 2D");
173 s->SetElementName("Scene - 2D");
174
175 auto mng = new TEveProjectionManager();
176 mng->SetProjection(t);
177
178 auto axes = new TEveProjectionAxes(mng);
179 s->AddElement(axes);
180 TEveCalo2D* calo2d = (TEveCalo2D*) mng->ImportElements(calo3d);
181 s->AddElement(calo2d);
182
183 v->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
184
185 gEve->AddToListTree(mng, kTRUE);
186 gEve->AddToListTree(calo2d, kTRUE);
187
188 return calo2d;
189}
190
191//______________________________________________________________________________
192void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s)
193{
194 // Create a scene and a viewer in the given slot.
195
196 v = new TEveViewer("Viewer");
197 v->SpawnGLViewer(gEve->GetEditor());
198 slot->ReplaceWindow(v);
200 s = gEve->SpawnNewScene("Scene");
201 v->AddScene(s);
202}
203
204//______________________________________________________________________________
205void add_jet(TEveElement* parent, const char* name,
206 Float_t eta, Float_t phi,
207 Float_t deta, Float_t dphi)
208{
209 auto jet = new TEveJetCone(name, name);
210 jet->SetMainTransparency(60);
211 jet->SetLineColor(kRed);
212 jet->SetCylinder(129 - 10, 268.36 - 10);
213 jet->AddEllipticCone(eta, phi, deta, dphi);
214 jet->SetPickable(kTRUE);
215 jet->SetHighlightFrame(kFALSE);
216 parent->AddElement(jet);
217}
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
@ kRed
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
R__EXTERN TEveManager * gEve
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
Visualization of a calorimeter event data in 2D.
Definition TEveCalo.h:202
Visualization of a calorimeter event data in 3D.
Definition TEveCalo.h:158
A central manager for calorimeter data of an event written in TH2F.
A central manager for calorimeter event data.
GL-overlay control GUI for TEveCaloLego.
void SetCaloLego(TEveCaloLego *c)
Visualization of calorimeter data as eta/phi histogram.
Definition TEveCalo.h:251
void SetElementName(const char *name) override
Virtual function for setting of name of an element.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition TEveElement.h:36
virtual void AddElement(TEveElement *el)
Add el to the list of children.
Draws a jet cone with leading particle is specified in (eta,phi) and cone radius is given.
Definition TEveJetCone.h:24
A base class of TGLEventHandler.
TEveViewerList * GetViewers() const
TEveViewer * GetDefaultViewer() const
Returns the default viewer - the first one in the fViewers list.
TEveBrowser * GetBrowser() const
TEveGedEditor * GetEditor() const
Returns main object editor.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=nullptr)
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
TEveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
TEveScene * GetEventScene() const
Axes for non-linear projections.
Manager class for steering of projections and managing projected objects.
Eve representation of TGLScene.
Definition TEveScene.h:27
void AddElement(TEveElement *el) override
Call base-class implementation.
Eve representation of TGLViewer.
Definition TEveViewer.h:31
Description of TEveWindowSlot.
Definition TEveWindow.h:302
void ReplaceWindow(TEveWindow *w)
Replace this window with the passed one.
static TEveWindowSlot * CreateWindowInTab(TGTab *tab, TEveWindow *eve_parent=nullptr)
Create a new tab in a given tab-widget and populate it with a default window-slot.
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:4089
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4626
@ kCameraOrthoXOY
Definition TGLViewer.h:62
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:558
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
TGTab * GetTabRight() const
const char * histFile
void add_jet(REveElement *parent, const char *name, Float_t eta, Float_t phi, Float_t deta, Float_t dphi)
void calorimeters()
void lego()
Definition lego.C:31
constexpr Double_t Pi()
Definition TMath.h:37
constexpr Double_t TwoPi()
Definition TMath.h:44