Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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->SetLineColor(kBlue);
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();
}
int Int_t
Definition RtypesCore.h:45
@ kRed
Definition Rtypes.h:66
@ kBlack
Definition Rtypes.h:65
@ kGreen
Definition Rtypes.h:66
@ kMagenta
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
#define gPad
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
Class describing rotation + translation.
Definition TGeoMatrix.h:317
void RegisterYourself() override
Register the matrix in the current manager, which will become the owner.
void SetTranslation(const TGeoTranslation &tr)
copy the translation component
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=nullptr)
Add a track to the list of tracks.
TVirtualGeoTrack * GetTrack(Int_t index)
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
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.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
Base class describing materials.
void SetTransparency(Char_t transparency=0)
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void Draw(Option_t *option="") override
draw top volume according to option
void SetLineColor(Color_t lcolor) override
Set the line color.
Online http server for arbitrary ROOT application.
Definition THttpServer.h:31
Bool_t Register(const char *subfolder, TObject *obj)
Register object in subfolder.
Bool_t Unregister(TObject *obj)
Unregister object.
Bool_t SetItemField(const char *fullname, const char *name, const char *value)
Set item field in sniffer.
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
virtual void TurnOn()
Add the timer to the system timer list.
Definition TTimer.cxx:243
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Author
Sergey Linev

Definition in file httpgeom.C.