Complex example showing ALICE ESD visualization in several views.
No ALICE code is needed, only four simple coordinate-transformation functions declared in this macro.
A simple geometry of 10KB, extracted from the full TGeo-geometry, is used to outline the central detectors of ALICE.
All files are access from the web by using the "CACHEREAD" option.
To be able to access the event data in a natural way, by using data-members of classes and object containers, the header files and class dictionaries are automatically generated from the TStreamerInfo classes stored in the ESD file by using the TFile::MakeProject() function. The header files and a shared library is created in the aliesd/ directory and can be loaded dynamically into the ROOT session.
Most common use of the event-display is to browse through a collection of events. Thus a simple GUI allowing this is created in the function make_gui().
Eve uses the configurable ROOT-browser as its main window and so we create an extra tab in the left working area of the browser and provide backward/forward buttons.
As this is a simple macro, we store the information about the current event in the global variable 'Int_t esd_event_id'. The functions for event-navigation simply modify this variable and call the load_event() function which does the following:
#include "aliesd/AliESDEvent.h"
#include "aliesd/AliESDRun.h"
#include "aliesd/AliESDtrack.h"
class AliESDEvent;
class AliESDfriend;
class AliESDtrack;
class AliExternalTrackParam;
void make_gui();
void load_event();
void update_projections();
void alice_esd_read();
AliExternalTrackParam* tp=0);
void trackGetPos(AliExternalTrackParam* tp,
Double_t r[3]);
void trackGetMomentum(AliExternalTrackParam* tp,
Double_t p[3]);
Double_t trackGetP(AliExternalTrackParam* tp);
const char* esd_file_name = "http://root.cern.ch/files/alice_ESDs.root";
const char* esd_friends_file_name = "http://root.cern.ch/files/alice_ESDfriends.root";
const char* esd_geom_file_name = "http://root.cern.ch/files/alice_ESDgeometry.root";
TFile *esd_file =
nullptr;
TFile *esd_friends_file =
nullptr;
TTree *esd_tree =
nullptr;
AliESDEvent *esd = nullptr;
AliESDfriend *esd_friend = nullptr;
{
printf("*** Opening ESD ***\n");
if (!esd_file)
return;
printf("*** Opening ESD-friends ***\n");
esd_friends_file =
TFile::Open(esd_friends_file_name,
"CACHEREAD");
if (!esd_friends_file)
return;
esd_tree = (
TTree*) esd_file->
Get(
"esdTree");
{
TIter next(esd->fESDObjects);
{
if(bname.CompareTo("AliESDfriend")==0)
{
}
else
{
}
}
}
if (auto_size)
{
if (screen_ratio > 1.5) {
} else {
}
}
{
if (!geom)
return;
delete geom;
}
make_gui();
if (gRPhiMgr) {
gRPhiMgr->ImportElements(gGeoShape);
}
if (gRhoZMgr) {
gRhoZMgr->ImportElements(gGeoShape);
}
load_event();
update_projections();
}
void load_event()
{
printf("Loading event %d.\n", esd_event_id);
gTextEntry->
SetText(
Form(
"Loading event %d...",esd_event_id));
if (track_list)
alice_esd_read();
gTextEntry->
SetText(
Form(
"Event %d loaded",esd_event_id));
gROOT->ProcessLine(
"SplitGLView::UpdateSummary()");
}
void update_projections()
{
if (gRPhiMgr && top) {
gRPhiMgr->ImportElements(gGeoShape);
gRPhiMgr->ImportElements(top);
}
if (gRhoZMgr && top) {
gRhoZMgr->DestroyElements();
gRhoZMgr->ImportElements(gGeoShape);
gRhoZMgr->ImportElements(top);
}
}
class EvNavHandler
{
public:
void Fwd()
{
if (esd_event_id < esd_tree->GetEntries() - 1) {
++esd_event_id;
load_event();
update_projections();
} else {
gTextEntry->
SetText(
"Already at last event");
printf("Already at last event.\n");
}
}
void Bck()
{
if (esd_event_id > 0) {
--esd_event_id;
load_event();
update_projections();
} else {
gTextEntry->
SetText(
"Already at first event");
printf("Already at first event.\n");
}
}
};
void make_gui()
{
gROOT->ProcessLine(
".L SplitGLView.C+");
browser->
ExecPlugin(
"SplitGLView", 0,
"new SplitGLView(gClient->GetRoot(), 600, 450, kTRUE)");
{
EvNavHandler *fh = new EvNavHandler;
b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Bck()");
b->Connect(
"Clicked()",
"EvNavHandler", fh,
"Fwd()");
}
}
enum ESDTrackFlags {
kITSin=0x0001,kITSout=0x0002,kITSrefit=0x0004,kITSpid=0x0008,
kTPCin=0x0010,kTPCout=0x0020,kTPCrefit=0x0040,kTPCpid=0x0080,
kTRDin=0x0100,kTRDout=0x0200,kTRDrefit=0x0400,kTRDpid=0x0800,
kTOFin=0x1000,kTOFout=0x2000,kTOFrefit=0x4000,kTOFpid=0x8000,
kHMPIDpid=0x20000,
kEMCALmatch=0x40000,
kTRDbackup=0x80000,
kTRDStop=0x20000000,
kESDpid=0x40000000,
kTIME=0x80000000
};
void alice_esd_read()
{
AliESDRun *esdrun = (AliESDRun*) esd->fESDObjects->FindObject("AliESDRun");
if (track_list == 0) {
}
{
AliESDtrack* at = (AliESDtrack*)
tracks->At(
n);
AliExternalTrackParam* tp = at;
if (! trackIsOn(at, kITSrefit)) {
tp = at->fIp;
}
TEveTrack* track = esd_make_track(trkProp,
n, at, tp);
}
}
AliESDtrack* at,
AliExternalTrackParam* tp)
{
if (tp == 0) tp = at;
rt.
fSign = (tp->fP[4] > 0) ? 1 : -1;
trackGetPos(tp, vbuf); rt.
fV.
Set(vbuf);
trackGetMomentum(tp, pbuf); rt.
fP.
Set(pbuf);
return track;
}
{
return (t->fFlags &
mask) > 0;
}
void trackGetPos(AliExternalTrackParam* tp,
Double_t r[3])
{
r[0] = tp->
fX;
r[1] = tp->fP[0];
r[2] = tp->fP[1];
r[0] =
x*cs -
r[1]*sn;
r[1] =
x*sn +
r[1]*cs;
}
void trackGetMomentum(AliExternalTrackParam* tp,
Double_t p[3])
{
p[0] = tp->fP[4];
p[1] = tp->fP[2];
p[2] = tp->fP[3];
}
Double_t trackGetP(AliExternalTrackParam* tp)
{
}
ULong_t Pixel_t
Pixel value.
R__EXTERN TEveManager * gEve
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
An array of clone (identical) objects.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Specialization of TRootBrowser for Eve.
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
virtual void AddElement(TEveElement *el)
Add el to the list of children.
TEveElement * FindChild(const TString &name, const TClass *cls=nullptr)
Find the first child with given name.
virtual void DestroyElements()
Destroy all children of this element.
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=nullptr)
Import a shape extract 'gse' under element 'parent'.
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
void AddGlobalElement(TEveElement *element, TEveElement *parent=nullptr)
Add a global element, i.e.
TEveSceneList * GetScenes() const
TEveBrowser * GetBrowser() const
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)
TEveEventManager * GetCurrentEvent() const
Axes for non-linear projections.
Manager class for steering of projections and managing projected objects.
A list of tracks supporting change of common attributes and selection based on track parameters.
void SetMarkerStyle(Style_t s) override
Set marker style for the list and the elements.
void SetMarkerColor(Color_t c) override
Set marker color for the list and the elements.
void SetMainColor(Color_t c) override
Set main (line) color for the list and the elements.
void SetMarkerSize(Size_t s) override
Set marker size for the list and the elements.
void MakeTracks(Bool_t recurse=kTRUE)
Regenerate the visual representations of tracks.
TEveTrackPropagator * GetPropagator()
Holding structure for a number of track rendering parameters.
void SetMagField(Double_t bX, Double_t bY, Double_t bZ)
Set constant magnetic field and rebuild tracks.
Visual representation of a track.
void SetAttLineAttMarker(TEveTrackList *tl)
Set line and marker attributes from TEveTrackList.
virtual void SetStdTitle()
Set standard track title based on most data-member values.
void Set(const Float_t *v)
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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.
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.
void Close(Option_t *option="") override
Close a file.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
void MapWindow() override
map window
void Move(Int_t x, Int_t y) override
Move frame.
void ShowPosition(Bool_t set=kTRUE, Bool_t percent=kTRUE, const char *format="%.2f")
Show postion text, either in percent or formatted according format.
A composite frame that layout their children in horizontal way.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
void Increment(Float_t inc)
Increment progress position.
virtual void SetBarColor(Pixel_t color)
Set progress bar color.
virtual void Reset()
Reset progress bar (i.e. set pos to 0).
A TGTextEntry is a one line text input widget.
void SetEnabled(Bool_t flag=kTRUE)
virtual void SetTextColor(Pixel_t color, Bool_t local=kTRUE)
Changes text color.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
The TNamed class is the base class for all named ROOT classes.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual void SetName(const char *name)
Change (i.e.
void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1) override
Start embedding external frame in the tab "pos" and tab element "subpos".
void SetTabTitle(const char *title, Int_t pos=kRight, Int_t subpos=-1)
Set text "title" of Tab "subpos" in TGTab "pos".
Longptr_t ExecPlugin(const char *name=nullptr, const char *fname=nullptr, const char *cmd=nullptr, Int_t pos=kRight, Int_t subpos=-1) override
Execute a macro and embed the created frame in the tab "pos" and tab element "subpos".
void StopEmbedding(const char *name=nullptr) override
virtual void ShowCloseTab(Bool_t show)
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
A TTree represents a columnar dataset.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
virtual TList * GetUserInfo()
Return a pointer to the list containing user objects associated to this tree.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.