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

Detailed Description

Demonstrates usage pre-scaling for automatic 2D projections.

#include <sstream>
#include <iostream>
#include "TGeoManager.h"
#include "TGeoVolume.h"
#include "TGeoMaterial.h"
#include "TGeoMatrix.h"
#include "TSystem.h"
#include "TFile.h"
#include "TRandom.h"
namespace REX = ROOT::Experimental;
REX::REvePointSet *getPointSet(int npoints = 2, float s = 2, int color = 28)
{
auto ps = new REX::REvePointSet("testPnts", "title", npoints);
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(3 + r.Uniform(1, 2));
// ps->SetMarkerStyle(4);
return ps;
}
void makeProjectedViewsAndScene(REX::REveProjection::EPType_e type, bool scale)
{
auto rPhiGeomScene = eveMng->SpawnNewScene(Form("Project%s Geo", scale ? "PreScaled" : ""));
auto rPhiEventScene = eveMng->SpawnNewScene(Form("Project%s Event", scale ? "PreScaled" : ""));
if (scale) {
REX::REveProjection *p = mngRhoPhi->GetProjection();
p->AddPreScaleEntry(0, 0, 4); // r scale 4 from 0
p->AddPreScaleEntry(0, 45, 1); // r scale 1 from 45
p->AddPreScaleEntry(0, 310, 0.5);
p->SetUsePreScale(kTRUE);
}
auto rphiView = eveMng->SpawnNewViewer("Projected View", "");
rphiView->AddScene(rPhiGeomScene);
rphiView->SetCameraType(REX::REveViewer::kCameraOrthoXOY);
for (auto &ie : eveMng->GetGlobalScene()->RefChildren())
mngRhoPhi->ImportElements(ie, rPhiGeomScene);
for (auto &ie : eveMng->GetEventScene()->RefChildren())
mngRhoPhi->ImportElements(ie, rPhiEventScene);
}
TGeoNode *getNodeFromPath(TGeoNode *top, std::string path)
{
TGeoNode *node = top;
istringstream f(path);
string s;
while (getline(f, s, '/'))
node = node->GetVolume()->FindNode(s.c_str());
return node;
}
void projection_prescale(std::string type = "RPhi")
{
eveMng = REX::REveManager::Create();
// static scene
auto geoManager = eveMng->GetGeometry("http://root.cern/files/cms.root");
TGeoNode *top = geoManager->GetTopVolume()->FindNode("CMSE_1");
auto holder = new REX::REveElement("MUON");
eveMng->GetGlobalScene()->AddElement(holder);
auto n = getNodeFromPath(top, "MUON_1/MB_1");
auto m = new REX::REveGeoShape("MB_1");
m->SetShape(n->GetVolume()->GetShape());
m->SetMainColor(kOrange);
holder->AddElement(m);
auto bv = n->GetVolume();
for (int i = 1; i < 5; ++i) {
auto n = bv->FindNode(Form("MBXC_%d", i));
auto gss = n->GetVolume()->GetShape();
auto b1s = new REX::REveGeoShape(Form("Arc %d", i));
b1s->InitMainTrans();
const double *move = n->GetMatrix()->GetTranslation();
b1s->RefMainTrans().SetFrom(*(n->GetMatrix()));
b1s->SetShape(gss);
b1s->SetMainColor(kBlue);
holder->AddElement(b1s);
}
// event scene
auto line = new REX::REveLine();
line->SetNextPoint(0, 0, 0);
float a = 300;
line->SetNextPoint(a, a, a);
eveMng->GetEventScene()->AddElement(line);
auto line2 = new REX::REveLine();
line2->SetNextPoint(0, 0, 0);
float b = 30;
line2->SetNextPoint(b, b + 5, b);
line2->SetMainColor(kRed);
eveMng->GetEventScene()->AddElement(line2);
auto points = getPointSet(10, 30);
eveMng->GetEventScene()->AddElement(points);
// make scaled and plain projected views
if (type == "RPhi") {
makeProjectedViewsAndScene(REX::REveProjection::kPT_RPhi, true);
makeProjectedViewsAndScene(REX::REveProjection::kPT_RPhi, false);
} else {
makeProjectedViewsAndScene(REX::REveProjection::kPT_RhoZ, true);
makeProjectedViewsAndScene(REX::REveProjection::kPT_RhoZ, false);
}
eveMng->Show();
}
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
@ kRed
Definition Rtypes.h:67
@ kOrange
Definition Rtypes.h:68
@ kBlue
Definition Rtypes.h:67
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 points
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
R__EXTERN TRandom * gRandom
Definition TRandom.h:73
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
REveLine An arbitrary polyline with fixed line and marker attributes.
Definition REveLine.hxx:30
REveProjectionManager Manager class for steering of projections and managing projected objects.
REveProjection Base for specific classes that implement non-linear projections.
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.
Definition TFile.cxx:4338
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:100
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
This is the base class for the ROOT Random number generators.
Definition TRandom.h:28
TLine * line
const Int_t n
Definition legend1.C:16
Namespace for ROOT features in testing.
Definition TROOT.h:100
TMarker m
Definition textangle.C:8
Author
Matevz Tadel

Definition in file projection_prescale.C.