Functions
genie::utils::geometry Namespace Reference

Geometry utilities. More...

Functions

void RecursiveExhaust (TGeoVolume *topvol, string volnames, bool exhaust)
 

Detailed Description

Geometry utilities.

Author
Costas Andreopoulos <costas.andreopoulos stfc.ac.uk> University of Liverpool & STFC Rutherford Appleton Lab

March 26, 2009

Copyright (c) 2003-2019, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org or see $GENIE/LICENSE

Function Documentation

void genie::utils::geometry::RecursiveExhaust ( TGeoVolume *  topvol,
string  volnames,
bool  exhaust 
)

Definition at line 26 of file GeoUtils.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, demo0::length, and nd.

Referenced by GetGeometry(), and main().

28 {
29 // contributed by Jacek Holeczek
30 //
31 //
32  if (!topvol) return; // just a precaution
33 
34  // check if the "current volume" is in the list of volumes
35  if (topvol->GetName()) // non-null pointer to volume name?
36  {
37  const char *name = topvol->GetName();
38  size_t length = strlen(name);
39  if (length) // non-empty volume name?
40  {
41  size_t ind = 0;
42  while ( (ind = volnames.find_first_of("+-", ind)) != std::string::npos )
43  {
44  ind += 1;
45  if (ind == volnames.length()) break; // just a precaution
46  if ( (!(volnames.compare(ind, length, name))) &&
47  ( ((ind + length) == volnames.length()) ||
48  (volnames[(ind + length)] == '+') ||
49  (volnames[(ind + length)] == '-') ||
50  (volnames[(ind + length)] == ' ') ) )
51  {
52  // a "match" is found ... now check what to do with it
53  if ( volnames[(ind - 1)] == '+')
54  exhaust = false;
55  else if ( volnames[(ind - 1)] == '-')
56  exhaust = true;
57  break; // we are done
58  }
59  }
60  }
61  }
62 
63 #if defined(DEBUG_RECURSIVE_EXHAUST)
64  std::cout << topvol->GetName()
65  << " <" << topvol->GetMedium()->GetName() << ">"
66  << " : " << exhaust << " :";
67 #endif /* defined(DEBUG_RECURSIVE_EXHAUST) */
68 
69  // "exhaust" the "current top volume" if requested
70  if (exhaust)
71  {
72  static TGeoMaterial *matVacuum = ((TGeoMaterial *)0);
73  static TGeoMedium *Vacuum = ((TGeoMedium *)0);
74 
75  if (!Vacuum)
76  {
77 #if defined(DEBUG_RECURSIVE_EXHAUST)
78  std::cout << " Creating the Vaccum material and medium :";
79 #endif /* defined(DEBUG_RECURSIVE_EXHAUST) */
80  // Actually ... one should check if the "Vacuum" TGeoMaterial and
81  // TGeoMedium are already defined in the geometry and, if found,
82  // re-use them ... but I was too lazy to implement it here, sorry.
83  if (!matVacuum) matVacuum = new TGeoMaterial("Vacuum", 0.0, 0.0, 0.0);
84  if (matVacuum) Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
85  }
86 
87  if (Vacuum) topvol->SetMedium(Vacuum); // "exhaust" volume
88  }
89 
90 #if defined(DEBUG_RECURSIVE_EXHAUST)
91  std::cout << " <" << topvol->GetMedium()->GetName() << ">"
92  << std::endl;
93 #endif /* defined(DEBUG_RECURSIVE_EXHAUST) */
94 
95  // proceed with all daughters of the "current volume"
96  Int_t nd = topvol->GetNdaughters();
97  for (Int_t i = 0; i < nd; i++)
98  {
99  // non-null pointer to node?
100  if (topvol->GetNode(i)) {
102  topvol->GetNode(i)->GetVolume(), volnames, exhaust);
103  }
104  }
105 }
const XML_Char * name
Definition: expat.h:151
length
Definition: demo0.py:21
OStream cout
Definition: OStream.cxx:6
void RecursiveExhaust(TGeoVolume *topvol, string volnames, bool exhaust)
Definition: GeoUtils.cxx:26