Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TGeoRegion.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Andrei Gheata 18/10/17
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoRegion
13\ingroup Geometry_classes
14
15Regions are groups of volumes having a common set of user tracking cuts.
16
17Class wrapper for regions used by Monte Carlo packages
18A region is composed by a list of logical volumes and defines a set
19of cuts. Used mainly to transport region information stored in
20GDML format to the clients requiring it from the transient geometry.
21
22*/
23
24#include "TGeoRegion.h"
25
26#include "TGeoManager.h"
27
28
29////////////////////////////////////////////////////////////////////////////////
30/// Region destructor.
31
33{
34 fCuts.Delete();
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Region copy constructor.
40{
41 for (int i = 0; i < other.GetNcuts(); ++i)
42 AddCut(*other.GetCut(i));
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Assignment operator.
48{
49 if (&other != this) {
50 TNamed::operator=(other);
51 fVolumes.operator=(other.fVolumes);
52 for (int i = 0; i < other.GetNcuts(); ++i)
53 AddCut(*(TGeoRegionCut *)other.fCuts.At(i));
54 }
55 return *this;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Add an existing volume to the region.
60bool TGeoRegion::AddVolume(const char *name)
61{
62 if (!gGeoManager)
63 return kFALSE;
64 TGeoVolume *vol = gGeoManager->GetVolume(name);
65 if (!vol)
66 return kFALSE;
67 AddVolume(vol);
68 return kTRUE;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Add cut to the region.
73void TGeoRegion::AddCut(const char *name, Double_t cut)
74{
75 fCuts.Add(new TGeoRegionCut(name, cut));
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Add an identical cut to the region.
80void TGeoRegion::AddCut(const TGeoRegionCut &regioncut)
81{
82 fCuts.Add(new TGeoRegionCut(regioncut));
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Print region info
88{
89 printf("== Region: %s\n", GetName());
90 printf(" volumes: ");
91 for (int i = 0; i < GetNvolumes(); ++i)
92 printf("%s ", GetVolume(i)->GetName());
93 printf("\n");
94 for (int i = 0; i < GetNcuts(); ++i)
95 printf(" %s value %g\n", GetCut(i)->GetName(), GetCut(i)->GetCut());
96}
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
char name[80]
Definition TGX11.cxx:148
externTGeoManager * gGeoManager
TGeoRegionCut * GetCut(int i) const
Definition TGeoRegion.h:58
TGeoRegion & operator=(const TGeoRegion &other)
Assignment operator.
TObjArray fVolumes
Definition TGeoRegion.h:38
~TGeoRegion() override
Region destructor.
void AddCut(const char *name, Double_t cut)
Add cut to the region.
TObjArray fCuts
Definition TGeoRegion.h:39
int GetNvolumes() const
Definition TGeoRegion.h:51
void Print(Option_t *option="") const override
Print region info.
TGeoVolume * GetVolume(int i) const
Definition TGeoRegion.h:52
void AddVolume(TGeoVolume *vol)
Definition TGeoRegion.h:49
int GetNcuts() const
Definition TGeoRegion.h:57
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
TNamed()
Definition TNamed.h:38
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:50
TObject * At(Int_t idx) const override
Definition TObjArray.h:170