EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FairGeoMedia.cxx
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FairGeoMedia.cxx
1
//*-- AUTHOR : Ilse Koenig
2
//*-- Last modified : 10/11/03 by Ilse Koenig
3
5
// FairGeoMedia
6
//
7
// Class for materials and media
8
//
10
11
#include "
FairGeoMedia.h
"
12
#include "
FairGeoMedium.h
"
13
14
#include "TList.h"
15
16
#include <iostream>
17
18
using
std::cout;
19
using
std::endl;
20
21
ClassImp
(
FairGeoMedia
)
22
23
FairGeoMedia
::
FairGeoMedia
()
24
: TNamed(),
25
media(new TList()),
26
inputFile(""),
27
author
(""),
28
description("")
29
{
30
// Constructor
31
}
32
33
FairGeoMedia::~FairGeoMedia
()
34
{
35
// Destructor
36
if
(
media
) {
37
media
->Delete();
38
delete
media
;
39
media
=0;
40
}
41
}
42
43
FairGeoMedium
*
FairGeoMedia::getMedium
(
const
char
* mediumName)
44
{
45
// Returns the medium with name mediumName
46
return
(
FairGeoMedium
*)
media
->FindObject(mediumName);
47
}
48
49
void
FairGeoMedia::addMedium
(
FairGeoMedium
*
m
)
50
{
51
// Adds a medium to the list of media
52
media
->Add(m);
53
}
54
55
void
FairGeoMedia::list
()
56
{
57
// Lists all media
58
cout<<
"********************************************************************\n"
;
59
cout<<
"List of media:\n"
;
60
TListIter iter(
media
);
61
FairGeoMedium
* medium;
62
while
((medium=(
FairGeoMedium
*)iter.Next())) {
63
cout<<
" "
<<medium->GetName()<<
"\n"
;
64
}
65
}
66
67
void
FairGeoMedia::print
()
68
{
69
// Prints the media
70
if
(!
author
.IsNull()) { cout<<
"//Author: "
<<
author
<<
'\n'
; }
71
if
(!
description
.IsNull()) { cout<<
"//Description: "
<<
description
<<
'\n'
; }
72
cout<<
"//----------------------------------------------------------\n"
;
73
TListIter iter(
media
);
74
FairGeoMedium
* medium;
75
Int_t i=0;
76
while
((medium=(
FairGeoMedium
*)iter.Next())) {
77
if
(medium->
getAutoFlag
()!=0) {
78
medium->
print
();
79
i++;
80
}
81
}
82
if
(i!=
media
->GetSize()) {
83
iter.Reset();
84
cout<<
"//----------------------------------------------\n"
;
85
cout<<
"AUTONULL\n"
;
86
cout<<
"//----------------------------------------------\n"
;
87
while
((medium=(
FairGeoMedium
*)iter.Next())) {
88
if
(medium->
getAutoFlag
()==0) { medium->
print
(); }
89
}
90
}
91
}
92
93
void
FairGeoMedia::read
(std::fstream& fin)
94
{
95
// Reads the media from file
96
cout<<
"-I- FairGeoMedia Read media"
<<endl;
97
const
Int_t maxBuf=256;
98
char
buf[maxBuf];
99
Int_t autoflag=1;
100
while
(!fin.eof()) {
101
fin>>buf;
102
if
(buf[0]==
'\0'
|| buf[0]==
'/'
) { fin.getline(buf,maxBuf); }
103
else
if
(fin.eof()) {
break
; }
104
else
{
105
TString eleName(buf);
106
if
(eleName.CompareTo(
"AUTONULL"
)!=0) {
107
FairGeoMedium
* medium=
new
FairGeoMedium
(eleName);
108
medium->
read
(fin,autoflag);
109
media
->Add(medium);
110
}
else
{ autoflag=0; }
111
}
112
}
113
}
114
115
void
FairGeoMedia::write
(std::fstream& fout)
116
{
117
// Writes the media to file
118
if
(!
author
.IsNull()) { fout<<
"//Author: "
<<
author
<<
'\n'
; }
119
if
(!
description
.IsNull()) { fout<<
"//Description: "
<<
description
<<
'\n'
; }
120
fout<<
"//----------------------------------------------------------\n"
;
121
TListIter iter(
media
);
122
FairGeoMedium
* medium;
123
Int_t i=0;
124
while
((medium=(
FairGeoMedium
*)iter.Next())) {
125
if
(medium->
getAutoFlag
()!=0) {
126
medium->
write
(fout);
127
i++;
128
}
129
}
130
if
(i!=
media
->GetSize()) {
131
iter.Reset();
132
fout<<
"//----------------------------------------------\n"
;
133
fout<<
"AUTONULL\n"
;
134
fout<<
"//----------------------------------------------\n"
;
135
while
((medium=(
FairGeoMedium
*)iter.Next())) {
136
if
(medium->
getAutoFlag
()==0) { medium->
write
(fout); }
137
}
138
}
139
}
EicRoot
blob
master
geobase
FairGeoMedia.cxx
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:36
using
1.8.2 with
EIC GitHub integration