Logo ROOT  
Reference Guide
httpgeom.C File Reference

Detailed Description

This program creates trivial geometry with several tracks and configure online monitoring of geometry via THttpServer Geometry regularly changed by the program and correspondent changes immediately seen in the browser

#include "THttpServer.h"
#include "TGeoManager.h"
#include "TGeoMaterial.h"
#include "TGeoMedium.h"
#include "TGeoVolume.h"
#include "TGeoTrack.h"
#include "TRandom.h"
#include "TTimer.h"
#include "TPad.h"
THttpServer *serv = nullptr;
bool drawing = false;
int interval = 2000;
void create_geo()
{
if (gGeoManager) {
delete gGeoManager;
}
new TGeoManager("world", "the simplest geometry");
if (serv) {
serv->Register("/", gGeoManager);
// enable monitoring and
// specify item to draw when page is opened
// serv->SetItemField("/","_layout","grid2x2");
serv->SetItemField("/","_monitoring",Form("%d",interval));
serv->SetItemField("/","_drawitem","world");
serv->SetItemField("/","_drawopt","tracks");
}
auto rnd = gRandom;
TGeoMaterial *mat = new TGeoMaterial("Vacuum",0,0,0);
mat->SetTransparency(50);
TGeoMedium *med = new TGeoMedium("Vacuum",1,mat);
TGeoVolume *top = gGeoManager->MakeBox("Top",med, 10+5*rnd->Rndm(), 10+5*rnd->Rndm(), 10+5*rnd->Rndm());
top->SetFillColor(3);
TGeoVolume *in = gGeoManager->MakeBox("In",med, 2.,2.,2.);
in->SetFillColor(2);
TGeoCombiTrans *tr = new TGeoCombiTrans("tr");
double x = -8+16*rnd->Rndm();
double y = -8+16*rnd->Rndm();
double z = -8+16*rnd->Rndm();
tr->SetTranslation (x, y, z);
top->AddNode(in, 1, tr);
if (rnd->Rndm() < 0.5)
else
for (int j=0; j<50; j++)
{
Int_t track_index = gGeoManager->AddTrack(2,22);
auto track = gGeoManager->GetTrack(track_index);
if (rnd->Rndm() < 0.5)
track->SetLineColor(kRed);
else
track->SetLineWidth(2);
track->AddPoint(x, y, z, 0);
track->AddPoint(-10 + 20*rnd->Rndm(), -10 + 20*rnd->Rndm(), -10 + 20*rnd->Rndm(), 0);
}
if (drawing) {
// add "showtop" option to display top volume in JSROOT
// gGeoManager->SetTopVisible();
top->Draw();
gPad->Modified();
gPad->Update();
}
}
void httpgeom()
{
drawing = false; // to enable canvas drawing
serv = new THttpServer("http:8090");
TTimer *timer = new TTimer("create_geo()", interval);
timer->TurnOn();
}
Author
Sergey Linev

Definition in file httpgeom.C.

TEveLine::SetLineWidth
virtual void SetLineWidth(Width_t lwidth)
Set line-style of the line.
Definition: TEveLine.cxx:106
TGeoMedium.h
TEveLine::SetLineColor
virtual void SetLineColor(Color_t col)
Definition: TEveLine.h:54
TGeoCombiTrans
Definition: TGeoMatrix.h:291
TGeoManager::MakeBox
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
Definition: TGeoManager.cxx:2918
THttpServer::SetItemField
Bool_t SetItemField(const char *fullname, const char *name, const char *value)
Definition: THttpServer.cxx:1184
kGreen
@ kGreen
Definition: Rtypes.h:66
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
Form
char * Form(const char *fmt,...)
TGeoManager::CloseGeometry
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
Definition: TGeoManager.cxx:1359
TRandom.h
Int_t
int Int_t
Definition: RtypesCore.h:45
TGeoVolume.h
TGeoVolume::AddNode
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:932
TPad.h
x
Double_t x[n]
Definition: legend1.C:17
TTimer.h
TGeoMaterial
Definition: TGeoMaterial.h:34
TGeoManager::DrawTracks
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
Definition: TGeoManager.cxx:1735
TGeoMaterial::SetTransparency
void SetTransparency(Char_t transparency=0)
Definition: TGeoMaterial.h:139
kBlack
@ kBlack
Definition: Rtypes.h:65
TGeoManager::SetTopVolume
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Definition: TGeoManager.cxx:3397
TTimer
Definition: TTimer.h:51
kMagenta
@ kMagenta
Definition: Rtypes.h:66
THttpServer
Definition: THttpServer.h:31
TGeoCombiTrans::RegisterYourself
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:1877
THttpServer::Register
Bool_t Register(const char *subfolder, TObject *obj)
Register object in subfolder.
Definition: THttpServer.cxx:980
TGeoVolume::Draw
virtual void Draw(Option_t *option="")
draw top volume according to option
Definition: TGeoVolume.cxx:1146
TGeoMaterial.h
TGeoTrack.h
gRandom
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
TGeoManager::GetTrack
TVirtualGeoTrack * GetTrack(Int_t index)
Definition: TGeoManager.h:398
y
Double_t y[n]
Definition: legend1.C:17
kRed
@ kRed
Definition: Rtypes.h:66
TGeoManager.h
THttpServer.h
TGeoManager::AddTrack
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=0)
Add a track to the list of tracks.
Definition: TGeoManager.cxx:642
kBlue
@ kBlue
Definition: Rtypes.h:66
TGeoCombiTrans::SetTranslation
void SetTranslation(const TGeoTranslation &tr)
copy the translation component
Definition: TGeoMatrix.cxx:2096
gPad
#define gPad
Definition: TVirtualPad.h:287
THttpServer::Unregister
Bool_t Unregister(TObject *obj)
Unregister object.
Definition: THttpServer.cxx:990
TGeoMedium
Definition: TGeoMedium.h:23
TTimer::TurnOn
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:241
TGeoVolume::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TGeoVolume.cxx:2035
TGeoManager
Definition: TGeoManager.h:44
TGeoVolume
Definition: TGeoVolume.h:44