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
32const char *histFile = "http://root.cern/files/cms_calo_hist.root";
33
39void add_jet(TEveElement *, const char *, Float_t, Float_t, Float_t, Float_t);
40
41void calorimeters()
42{
43 // gSystem->IgnoreSignal(kSigSegmentationViolation, true);
45
46 // event data
48 auto hf = TFile::Open(histFile, "CACHEREAD");
49 auto ecalHist = (TH2F *)hf->Get("ecalLego");
50 auto hcalHist = (TH2F *)hf->Get("hcalLego");
51 auto data = new TEveCaloDataHist();
52 data->AddHistogram(ecalHist);
53 data->RefSliceInfo(0).Setup("ECAL", 0.3, kBlue);
54 data->AddHistogram(hcalHist);
55 data->RefSliceInfo(1).Setup("HCAL", 0.1, kRed);
56 data->GetEtaBins()->SetTitleFont(120);
57 data->GetEtaBins()->SetTitle("h");
58 data->GetPhiBins()->SetTitleFont(120);
59 data->GetPhiBins()->SetTitle("f");
60 data->IncDenyDestroy();
62
63 // first tab
64 auto lego = MakeCaloLego(data, nullptr);
65
66 //
67 // second tab
68 //
69
70 // frames
72 auto packH = slot->MakePack();
73 packH->SetElementName("Projections");
74 packH->SetHorizontal();
75 packH->SetShowTitleBar(kFALSE);
76
77 slot = packH->NewSlot();
78 auto pack0 = slot->MakePack();
79 pack0->SetShowTitleBar(kFALSE);
80 auto slotLeftTop = pack0->NewSlot();
81 auto slotLeftBottom = pack0->NewSlot();
82
83 slot = packH->NewSlot();
84 auto pack1 = slot->MakePack();
85 pack1->SetShowTitleBar(kFALSE);
86 auto slotRightTop = pack1->NewSlot();
87 auto slotRightBottom = pack1->NewSlot();
88
89 // viewers ans scenes in second tab
94
97}
98
99//______________________________________________________________________________
101{
102 // Eta-phi lego view.
103
104 TEveViewer *v;
105 TEveScene *s;
106 if (slot) {
108 } else {
110 s = gEve->GetEventScene();
111 }
112 v->SetElementName("Viewer - Lego");
113 s->SetElementName("Scene - Lego");
114
115 auto lego = new TEveCaloLego(data);
116 s->AddElement(lego);
117
118 // By the default lego extends is (1x1x1). Resize it to put in 'natural'
119 // coordinates, so that y extend in 2*Pi and set height of lego two times
120 // smaller than y extend to have better view in 3D perspective.
121 lego->InitMainTrans();
122 lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
123
124 // draws scales and axis on borders of window
125 auto glv = v->GetGLViewer();
127 glv->AddOverlayElement(overlay);
128 overlay->SetCaloLego(lego);
129
130 // set event handler to move from perspective to orthographic view.
131 glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
132 glv->SetEventHandler(new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
134
135 return lego;
136}
137
138//______________________________________________________________________________
140{
141 // 3D cartesian view.
142
143 TEveViewer *v;
144 TEveScene *s;
146 v->SetElementName("Viewer - 3D");
147 s->SetElementName("Scene - 3D");
148
149 auto calo3d = new TEveCalo3D(data);
150 calo3d->SetBarrelRadius(129.00);
151 calo3d->SetEndCapPos(268.36);
152 s->AddElement(calo3d);
153
154 add_jet(calo3d, "JetCone Lojz", 1.4, 1.0, 0.4, 0.2);
155 add_jet(calo3d, "JetCone Mici", -2.0, -2.1, 0.2, 0.4);
156
157 return calo3d;
158}
159
160//______________________________________________________________________________
162{
163 // Projected calorimeter.
164
165 TEveViewer *v;
166 TEveScene *s;
168 v->SetElementName("Viewer - 2D");
169 s->SetElementName("Scene - 2D");
170
171 auto mng = new TEveProjectionManager();
172 mng->SetProjection(t);
173
174 auto axes = new TEveProjectionAxes(mng);
175 s->AddElement(axes);
176 TEveCalo2D *calo2d = (TEveCalo2D *)mng->ImportElements(calo3d);
177 s->AddElement(calo2d);
178
179 v->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
180
183
184 return calo2d;
185}
186
187//______________________________________________________________________________
189{
190 // Create a scene and a viewer in the given slot.
191
192 v = new TEveViewer("Viewer");
193 v->SpawnGLViewer(gEve->GetEditor());
194 slot->ReplaceWindow(v);
196 s = gEve->SpawnNewScene("Scene");
197 v->AddScene(s);
198}
199
200//______________________________________________________________________________
201void add_jet(TEveElement *parent, const char *name, Float_t eta, Float_t phi, Float_t deta, Float_t dphi)
202{
203 auto jet = new TEveJetCone(name, name);
204 jet->SetMainTransparency(60);
205 jet->SetLineColor(kRed);
206 jet->SetCylinder(129 - 10, 268.36 - 10);
207 jet->AddEllipticCone(eta, phi, deta, dphi);
208 jet->SetPickable(kTRUE);
209 jet->SetHighlightFrame(kFALSE);
210 parent->AddElement(jet);
211}
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kRed
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
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
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:4088
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:4625
@ 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:303
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