Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
calorimeters.C File Reference

Detailed Description

Demonstrates usage of EVE calorimetry classes.

#include "TSystem.h"
#include "TEveCalo.h"
#include "TEveWindow.h"
#include "TEveManager.h"
#include "TEveBrowser.h"
#include "TEveScene.h"
#include "TEveViewer.h"
#include "TEveTrans.h"
#include "TEveGedEditor.h"
#include "TEveJetCone.h"
#include "TGLWidget.h"
#include "TGLViewer.h"
#include "TGTab.h"
#include "TFile.h"
#include "TAxis.h"
const char* histFile =
"http://amraktad.web.cern.ch/amraktad/cms_calo_hist.root";
TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot);
TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot);
void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s);
{
// gSystem->IgnoreSignal(kSigSegmentationViolation, true);
// event data
auto hf = TFile::Open(histFile, "CACHEREAD");
auto ecalHist = (TH2F*)hf->Get("ecalLego");
auto hcalHist = (TH2F*)hf->Get("hcalLego");
auto data = new TEveCaloDataHist();
data->AddHistogram(ecalHist);
data->RefSliceInfo(0).Setup("ECAL", 0.3, kBlue);
data->AddHistogram(hcalHist);
data->RefSliceInfo(1).Setup("HCAL", 0.1, kRed);
data->GetEtaBins()->SetTitleFont(120);
data->GetEtaBins()->SetTitle("h");
data->GetPhiBins()->SetTitleFont(120);
data->GetPhiBins()->SetTitle("f");
data->IncDenyDestroy();
// first tab
auto lego = MakeCaloLego(data, 0);
//
// second tab
//
// frames
auto packH = slot->MakePack();
packH->SetElementName("Projections");
packH->SetHorizontal();
packH->SetShowTitleBar(kFALSE);
slot = packH->NewSlot();
auto pack0 = slot->MakePack();
pack0->SetShowTitleBar(kFALSE);
auto slotLeftTop = pack0->NewSlot();
auto slotLeftBottom = pack0->NewSlot();
slot = packH->NewSlot();
auto pack1 = slot->MakePack();
pack1->SetShowTitleBar(kFALSE);
auto slotRightTop = pack1->NewSlot();
auto slotRightBottom = pack1->NewSlot();
// viewers ans scenes in second tab
auto calo3d = MakeCalo3D(data, slotRightTop);
MakeCalo2D(calo3d, slotLeftTop, TEveProjection::kPT_RPhi);
MakeCalo2D(calo3d, slotLeftBottom, TEveProjection::kPT_RhoZ);
lego = MakeCaloLego(data, slotRightBottom);
}
//______________________________________________________________________________
TEveCaloLego* MakeCaloLego(TEveCaloData* data, TEveWindowSlot* slot)
{
// Eta-phi lego view.
if (slot) {
MakeViewerScene(slot, v, s);
} else {
}
v->SetElementName("Viewer - Lego");
s->SetElementName("Scene - Lego");
auto lego = new TEveCaloLego(data);
s->AddElement(lego);
// By the default lego extends is (1x1x1). Resize it to put in 'natural'
// coordinates, so that y extend in 2*Pi and set height of lego two times
// smaller than y extend to have better view in 3D perspective.
lego->InitMainTrans();
lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
// draws scales and axis on borders of window
auto glv = v->GetGLViewer();
glv->AddOverlayElement(overlay);
overlay->SetCaloLego(lego);
// set event handler to move from perspective to orthographic view.
glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
glv->SetEventHandler
(new TEveLegoEventHandler(glv->GetGLWidget(), glv, lego));
return lego;
}
//______________________________________________________________________________
TEveCalo3D* MakeCalo3D(TEveCaloData* data, TEveWindowSlot* slot)
{
// 3D cartesian view.
MakeViewerScene(slot, v, s);
v->SetElementName("Viewer - 3D");
s->SetElementName("Scene - 3D");
auto calo3d = new TEveCalo3D(data);
calo3d->SetBarrelRadius(129.00);
calo3d->SetEndCapPos(268.36);
s->AddElement(calo3d);
add_jet(calo3d, "JetCone Lojz", 1.4, 1.0, 0.4, 0.2);
add_jet(calo3d, "JetCone Mici", -2.0, -2.1, 0.2, 0.4);
return calo3d;
}
//______________________________________________________________________________
TEveCalo2D* MakeCalo2D(TEveCalo3D* calo3d, TEveWindowSlot* slot,
{
// Projected calorimeter.
MakeViewerScene(slot, v, s);
v->SetElementName("Viewer - 2D");
s->SetElementName("Scene - 2D");
auto mng = new TEveProjectionManager();
mng->SetProjection(t);
auto axes = new TEveProjectionAxes(mng);
s->AddElement(axes);
TEveCalo2D* calo2d = (TEveCalo2D*) mng->ImportElements(calo3d);
s->AddElement(calo2d);
v->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
return calo2d;
}
//______________________________________________________________________________
void MakeViewerScene(TEveWindowSlot* slot, TEveViewer*& v, TEveScene*& s)
{
// Create a scene and a viewer in the given slot.
v = new TEveViewer("Viewer");
v->SpawnGLViewer(gEve->GetEditor());
slot->ReplaceWindow(v);
s = gEve->SpawnNewScene("Scene");
v->AddScene(s);
}
//______________________________________________________________________________
void add_jet(TEveElement* parent, const char* name,
Float_t eta, Float_t phi,
Float_t deta, Float_t dphi)
{
auto jet = new TEveJetCone(name, name);
jet->SetMainTransparency(60);
jet->SetLineColor(kRed);
jet->SetCylinder(129 - 10, 268.36 - 10);
jet->AddEllipticCone(eta, phi, deta, dphi);
jet->SetPickable(kTRUE);
jet->SetHighlightFrame(kFALSE);
parent->AddElement(jet);
}
const Bool_t kFALSE
Definition RtypesCore.h:92
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
@ kRed
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
R__EXTERN TEveManager * gEve
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
virtual void SetElementName(const char *name)
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
TGListTreeItem * AddToListTree(TEveElement *re, Bool_t open, TGListTree *lt=0)
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.
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
virtual void AddElement(TEveElement *el)
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=0)
Create a new tab in a given tab-widget and populate it with a default window-slot.
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Definition TFile.h:324
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:3997
@ 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:509
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:251
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()
constexpr Double_t Pi()
Definition TMath.h:37
constexpr Double_t TwoPi()
Definition TMath.h:44
Author
Alja Mrak-Tadel

Definition in file calorimeters.C.