Logo ROOT  
Reference Guide
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 
15 Regions are groups of volumes having a common set of user tracking cuts.
16 
17 Class wrapper for regions used by Monte Carlo packages
18 A region is composed by a list of logical volumes and defines a set
19 of cuts. Used mainly to transport region information stored in
20 GDML format to the clients requiring it from the transient geometry.
21 
22 */
23 
24 #include "TGeoRegion.h"
25 
26 #include "TGeoManager.h"
27 
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// Region destructor.
33 
35 {
36  fCuts.Delete();
37 }
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Region copy constructor.
41 TGeoRegion::TGeoRegion(const TGeoRegion &other) : TNamed(other), fVolumes(other.fVolumes)
42 {
43  for (int i = 0; i < other.GetNcuts(); ++i)
44  AddCut(*other.GetCut(i));
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Assignment operator.
50 {
51  if (&other != this) {
52  TNamed::operator=(other);
53  fVolumes.operator=(other.fVolumes);
54  for (int i = 0; i < other.GetNcuts(); ++i)
55  AddCut(*(TGeoRegionCut *)other.fCuts.At(i));
56  }
57  return *this;
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Add an existing volume to the region.
62 bool TGeoRegion::AddVolume(const char *name)
63 {
64  if (!gGeoManager)
65  return kFALSE;
67  if (!vol)
68  return kFALSE;
69  AddVolume(vol);
70  return kTRUE;
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Add cut to the region.
75 void TGeoRegion::AddCut(const char *name, Double_t cut)
76 {
77  fCuts.Add(new TGeoRegionCut(name, cut));
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Add an identical cut to the region.
82 void TGeoRegion::AddCut(const TGeoRegionCut &regioncut)
83 {
84  fCuts.Add(new TGeoRegionCut(regioncut));
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Print region info
90 {
91  printf("== Region: %s\n", GetName());
92  printf(" volumes: ");
93  for (int i = 0; i < GetNvolumes(); ++i)
94  printf("%s ", GetVolume(i)->GetName());
95  printf("\n");
96  for (int i = 0; i < GetNcuts(); ++i)
97  printf(" %s value %g\n", GetCut(i)->GetName(), GetCut(i)->GetCut());
98 }
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TObjArray::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:356
Option_t
const char Option_t
Definition: RtypesCore.h:66
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
TNamed::operator=
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
TGeoRegion.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGeoRegionCut::GetCut
Double_t GetCut() const
Definition: TGeoRegion.h:30
TGeoRegion::fVolumes
TObjArray fVolumes
Definition: TGeoRegion.h:38
TObjArray::At
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
TGeoRegion::GetVolume
TGeoVolume * GetVolume(int i) const
Definition: TGeoRegion.h:52
TGeoRegion::Print
virtual void Print(Option_t *option="") const
Print region info.
Definition: TGeoRegion.cxx:89
TObjArray::Add
void Add(TObject *obj)
Definition: TObjArray.h:74
TGeoRegion::AddVolume
void AddVolume(TGeoVolume *vol)
Definition: TGeoRegion.h:49
TGeoRegion::~TGeoRegion
virtual ~TGeoRegion()
Region destructor.
Definition: TGeoRegion.cxx:34
TGeoRegion::AddCut
void AddCut(const char *name, Double_t cut)
Add cut to the region.
Definition: TGeoRegion.cxx:75
TGeoManager::GetVolume
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
Definition: TGeoManager.cxx:2712
TGeoRegion::TGeoRegion
TGeoRegion()
Definition: TGeoRegion.h:42
TGeoRegion::operator=
TGeoRegion & operator=(const TGeoRegion &other)
Assignment operator.
Definition: TGeoRegion.cxx:49
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TGeoRegion::fCuts
TObjArray fCuts
Definition: TGeoRegion.h:39
TGeoManager.h
TGeoRegion::GetCut
TGeoRegionCut * GetCut(int i) const
Definition: TGeoRegion.h:58
TGeoRegion
Regions are groups of volumes having a common set of user tracking cuts.
Definition: TGeoRegion.h:36
Double_t
double Double_t
Definition: RtypesCore.h:59
name
char name[80]
Definition: TGX11.cxx:110
TGeoRegionCut
Definition: TGeoRegion.h:20
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TGeoRegion::GetNvolumes
int GetNvolumes() const
Definition: TGeoRegion.h:51
TGeoVolume
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:49
TGeoRegion::GetNcuts
int GetNcuts() const
Definition: TGeoRegion.h:57