Logo ROOT   6.16/01
Reference Guide
parallel_world.C File Reference

Detailed Description

Misaligning geometry generate in many cases overlaps, due to the idealization of the design and the fact that in real life movements of the geometry volumes have constraints and are correlated.

This typically generates inconsistent response of the navigation methods, leading to inefficiencies during tracking, errors in the material budget calculations, and so on. Among those, there are dangerous cases when the hidden volumes are sensitive. This macro demonstrates how to use the "parallel world" feature to assign highest navigation priority to some physical paths in geometry.

void align();
//______________________________________________________________________________
void parallel_world(Bool_t usepw=kTRUE, Bool_t useovlp=kTRUE)
{
TGeoManager *geom = new TGeoManager("parallel_world", "Showcase for prioritized physical paths");
TGeoMaterial *matV = new TGeoMaterial("Vac", 0,0,0);
TGeoMedium *medV = new TGeoMedium("MEDVAC",1,matV);
TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *medAl = new TGeoMedium("MEDAL",2,matAl);
TGeoMaterial *matSi = new TGeoMaterial("Si", 28.085,14,2.329);
TGeoMedium *medSi = new TGeoMedium("MEDSI",3,matSi);
TGeoVolume *top = gGeoManager->MakeBox("TOP",medV,100,400,1000);
// Shape for the support block
TGeoBBox *sblock = new TGeoBBox("sblock", 20,10,2);
// The volume for the support
TGeoVolume *support = new TGeoVolume("block",sblock, medAl);
support->SetLineColor(kGreen);
// Shape for the sensor to be prioritized in case of overlap
TGeoBBox *ssensor = new TGeoBBox("sensor", 19,9,0.2);
// The volume for the sensor
TGeoVolume *sensor = new TGeoVolume("sensor",ssensor, medSi);
sensor->SetLineColor(kRed);
// Chip assembly of support+sensor
chip->AddNode(support, 1);
chip->AddNode(sensor,1, new TGeoTranslation(0,0,-2.1));
// A ladder that normally sags
TGeoBBox *sladder = new TGeoBBox("sladder", 20,300,5);
// The volume for the ladder
TGeoVolume *ladder = new TGeoVolume("ladder",sladder, medAl);
ladder->SetLineColor(kBlue);
// Add nodes
top->AddNode(ladder,1);
for (Int_t i=0; i<10; i++)
top->AddNode(chip, i+1, new TGeoTranslation(0, -225.+50.*i, 10));
if (usepw) pw = gGeoManager->CreateParallelWorld("priority_sensors");
// Align chips
align();
if (usepw) {
if (useovlp) pw->AddOverlap(ladder);
}
TString cname;
cname = usepw ? "cpw" : "cnopw";
TCanvas *c = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(cname);
if (c) c->cd();
else c = new TCanvas(cname, "",800,600);
top->Draw();
// top->RandomRays(0,0,0,0,sensor->GetName());
// Track random "particles" coming from the block side and draw only the tracklets
// actually crossing one of the sensors. Note that some of the tracks coming
// from the outer side may see the full sensor, while the others only part of it.
TStopwatch timer;
timer.Start();
top->RandomRays(100000,0,0,-30,sensor->GetName());
timer.Stop();
timer.Print();
TView3D *view = (TView3D*)gPad->GetView();
view->SetParallel();
view->Side();
if (usepw) pw->PrintDetectedOverlaps();
}
//______________________________________________________________________________
void align()
{
// Aligning 2 sensors so they will overlap with the support. One sensor is positioned
// normally while the other using the shared matrix
Double_t sag;
for (Int_t i=0; i<10; i++) {
node = gGeoManager->MakePhysicalNode(TString::Format("/TOP_1/chip_%d",i+1));
sag = 8.-0.494*(i-4.5)*(i-4.5);
TGeoTranslation *tr = new TGeoTranslation(0., -225.+50.*i, 10-sag);
node->Align(tr);
if (pw) pw->AddNode(TString::Format("/TOP_1/chip_%d",i+1));
}
}
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
@ kRed
Definition: Rtypes.h:63
@ kGreen
Definition: Rtypes.h:63
@ kBlue
Definition: Rtypes.h:63
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:572
#define gROOT
Definition: TROOT.h:410
#define gPad
Definition: TVirtualPad.h:286
The Canvas class.
Definition: TCanvas.h:31
Box class.
Definition: TGeoBBox.h:18
The manager class for any TGeo geometry.
Definition: TGeoManager.h:39
TGeoParallelWorld * GetParallelWorld() const
Definition: TGeoManager.h:565
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 SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
Makes a physical node corresponding to a path.
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
Base class describing materials.
Definition: TGeoMaterial.h:31
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
Base class for a flat parallel geometry.
Bool_t CloseGeometry()
The main geometry must be closed.
void AddNode(const char *path)
Add a node normally to this world. Overlapping nodes not allowed.
Int_t PrintDetectedOverlaps() const
Print the overlaps which were detected during real tracking.
void AddOverlap(TGeoVolume *vol, Bool_t activate=kTRUE)
To use this optimization, the user should declare the full list of volumes which may overlap with any...
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Bool_t Align(TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE, Double_t ovlp=0.001)
Align a physical node with a new relative matrix/shape.
Class describing translations.
Definition: TGeoMatrix.h:122
Volume assemblies.
Definition: TGeoVolume.h:308
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a component to the assembly.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:53
void RandomRays(Int_t nrays=10000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=0, Bool_t check_norm=kFALSE)
Random raytracing method.
virtual void Draw(Option_t *option="")
draw top volume according to option
virtual void SetLineColor(Color_t lcolor)
Set the line color.
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:984
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Stopwatch class.
Definition: TStopwatch.h:28
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:77
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
Basic string class.
Definition: TString.h:131
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2286
The 3D view class.
Definition: TView3D.h:29
virtual void Side()
Definition: TView3D.cxx:1932
virtual void SetParallel()
Set the parallel option (default).
Definition: TView3D.cxx:1303
Author
Andrei Gheata

Definition in file parallel_world.C.