18{
19
20
21
22 if (!topvol) return;
23
24
25 if (topvol->GetName())
26 {
27 const char *name = topvol->GetName();
28 size_t length = strlen(name);
29 if (length)
30 {
31 size_t ind = 0;
32 while ( (ind = volnames.find_first_of("+-", ind)) != std::string::npos )
33 {
34 ind += 1;
35 if (ind == volnames.length()) break;
36 if ( (!(volnames.compare(ind, length, name))) &&
37 ( ((ind + length) == volnames.length()) ||
38 (volnames[(ind + length)] == '+') ||
39 (volnames[(ind + length)] == '-') ||
40 (volnames[(ind + length)] == ' ') ) )
41 {
42
43 if ( volnames[(ind - 1)] == '+')
44 exhaust = false;
45 else if ( volnames[(ind - 1)] == '-')
46 exhaust = true;
47 break;
48 }
49 }
50 }
51 }
52
53#if defined(DEBUG_RECURSIVE_EXHAUST)
54 std::cout << topvol->GetName()
55 << " <" << topvol->GetMedium()->GetName() << ">"
56 << " : " << exhaust << " :";
57#endif
58
59
60 if (exhaust)
61 {
62 static TGeoMaterial *matVacuum = ((TGeoMaterial *)0);
63 static TGeoMedium *Vacuum = ((TGeoMedium *)0);
64
65 if (!Vacuum)
66 {
67#if defined(DEBUG_RECURSIVE_EXHAUST)
68 std::cout << " Creating the Vaccum material and medium :";
69#endif
70
71
72
73 if (!matVacuum) matVacuum = new TGeoMaterial("Vacuum", 0.0, 0.0, 0.0);
74 if (matVacuum) Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
75 }
76
77 if (Vacuum) topvol->SetMedium(Vacuum);
78 }
79
80#if defined(DEBUG_RECURSIVE_EXHAUST)
81 std::cout << " <" << topvol->GetMedium()->GetName() << ">"
82 << std::endl;
83#endif
84
85
86 Int_t nd = topvol->GetNdaughters();
87 for (Int_t i = 0; i < nd; i++)
88 {
89
90 if (topvol->GetNode(i)) {
92 topvol->GetNode(i)->GetVolume(), volnames, exhaust);
93 }
94 }
95}
void RecursiveExhaust(TGeoVolume *topvol, string volnames, bool exhaust)