This example display geometry, tracks and hits in web browser.
#include <vector>
#include <string>
#include <iostream>
{
for (
Int_t i = 0; i < npoints; ++i)
ps->SetNextPoint(
r.Uniform(-s, s),
r.Uniform(-s, s),
r.Uniform(-s, s));
ps->SetMarkerColor(color);
ps->SetMarkerSize(8);
ps->SetMarkerStyle(4);
return ps;
}
void addPoints()
{
auto ps1 = getPointSet(20, 100);
ps1->SetName("Points_1");
ps1->SetTitle("Points_1 title");
pntHolder->AddElement(ps1);
auto ps2 = getPointSet(10, 200, 4);
ps2->SetName("Points_2");
ps2->SetTitle("Points_2 title");
ps2->SetAlwaysSecSelect(true);
pntHolder->AddElement(ps2);
event->AddElement(pntHolder);
}
void addTracks()
{
int N_Tracks = 10 +
r.Integer(20);
for (int i = 0; i < N_Tracks; i++) {
int pdg = 11 * (
r.Integer(2) > 0 ? 1 : -1);
p.SetProductionVertex(
r.Uniform(-
v,
v),
r.Uniform(-
v,
v),
r.Uniform(-
v,
v), 1);
p.SetMomentum(
r.Uniform(-
m,
m),
r.Uniform(-
m,
m),
r.Uniform(-
m,
m) *
r.Uniform(1, 3), 1);
track->MakeTrack();
if (i % 4 == 3)
track->SetMainColor(
kBlue);
track->SetName(
Form(
"RandomTrack_%d", i));
track->SetTitle(
Form(
"RandomTrack_%d title", i));
trackHolder->AddElement(track);
}
event->AddElement(trackHolder);
}
void addJets()
{
int N_Jets = 5 +
r.Integer(5);
for (int i = 0; i < N_Jets; i++) {
jet->SetTitle(
Form(
"Jet_%d\n pT = %.2f", i,
r.Uniform(1, 40)));
jet->SetCylinder(2 * kR_max, 2 * kZ_d);
jet->AddEllipticCone(
r.Uniform(-3.5, 3.5),
r.Uniform(0,
TMath::TwoPi()),
r.Uniform(0.02, 0.2),
jet->SetFillColor(
kPink - 8);
jetHolder->AddElement(jet);
}
event->AddElement(jetHolder);
}
void makeEventScene()
{
addPoints();
addTracks();
addJets();
}
void makeGeometryScene()
{
b1->SetShape(
new TGeoTube(kR_min, kR_max, kZ_d));
b1->SetNSegments(80);
b1->SetMainTransparency(70);
b1->SetNSegments(40);
}
void createProjectionStuff()
{
rPhiEventScene = eveMng->
SpawnNewScene(
"RPhi Event Data",
"RPhi");
rhoZEventScene = eveMng->
SpawnNewScene(
"RhoZ Event Data",
"RhoZ");
}
void projectScenes(bool geomp, bool eventp)
{
if (geomp) {
for (auto &ie : eveMng->GetGlobalScene()->RefChildren()) {
}
}
if (eventp) {
int depth = 50;
for (auto &ie : eveMng->GetEventScene()->RefChildren()) {
depth -= 10;
}
}
}
private:
bool fAutoplay{false};
int fPlayDelay{10};
int fCount{0};
std::chrono::duration<double> fDeltaTime{1};
std::thread *fTimerThread{nullptr};
std::mutex fMutex;
std::condition_variable fCV;
public:
EventManager()
{
std::chrono::milliseconds ms(100);
fDeltaTime = ms;
}
~EventManager() override {}
void NextEvent()
{
makeEventScene();
projectScenes(false, true);
}
void autoplay_scheduler()
{
while (true) {
bool autoplay;
{
std::unique_lock<std::mutex> lock{fMutex};
if (!fAutoplay) {
return;
}
if (fCV.wait_for(lock, fDeltaTime) != std::cv_status::timeout) {
printf("autoplay not timed out \n");
if (!fAutoplay) {
printf("exit thread post wait\n");
return;
} else {
continue;
}
}
autoplay = fAutoplay;
}
if (autoplay) {
REX::REveManager::ChangeGuard ch;
NextEvent();
} else {
return;
}
}
}
void Autoplay()
{
static std::mutex autoplay_mutex;
std::unique_lock<std::mutex> aplock{autoplay_mutex};
{
std::unique_lock<std::mutex> lock{fMutex};
fAutoplay = !fAutoplay;
if (fAutoplay) {
if (fTimerThread) {
fTimerThread->join();
delete fTimerThread;
fTimerThread = nullptr;
}
NextEvent();
fTimerThread = new std::thread{[this] { autoplay_scheduler(); }};
} else {
fCV.notify_all();
}
}
}
virtual void QuitRoot()
{
printf("Quit ROOT\n");
REX::REveManager::QuitRoot();
}
};
void event_demo()
{
eveMng = REX::REveManager::Create();
auto eventMng = new EventManager();
eventMng->SetName("EventManager");
makeGeometryScene();
makeEventScene();
if (true) {
createProjectionStuff();
projectScenes(true, true);
}
}
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
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 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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual void DestroyElements()
Destroy all children of this element.
REveMagFieldDuo Interface to magnetic field with two different values depending on radius.
REveScene * GetEventScene() const
void AllowMultipleRemoteConnections(bool loopBack=true, bool useAuthKey=true)
Utility function to allow remote RWebWindow connections.
REveScene * GetGlobalScene() const
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
REveViewer * GetDefaultViewer() const
Get the default viewer.
REveScene * GetWorld() const
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveProjectionManager Manager class for steering of projections and managing projected objects.
void SetCurrentDepth(Float_t d)
virtual REveElement * ImportElements(REveElement *el, REveElement *ext_list=nullptr)
Recursively import elements and apply projection to the newly imported objects.
void AddCommand(const std::string &name, const std::string &icon, const REveElement *element, const std::string &action)
REveTrackPropagator Calculates path of a particle taking into account special path-marks and imposed ...
REveTrack Track with given vertex, momentum and optional referece-points (path-marks) along its path.
REveViewer Reve representation of TGLViewer.
void SetCameraType(REveCamera::ECameraType type)
Set camera by type (backward compatibility with old API)
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
Description of the dynamic properties of a particle.
This is the base class for the ROOT Random number generators.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Namespace for ROOT features in testing.
constexpr Double_t TwoPi()