CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
twikiExport.Material Class Reference

Public Member Functions

def __init__ (self, matString, comment)
 
def __str__ (self)
 
def addConstituent (self, constString, predefinedMaterials)
 
def getMass (self)
 
def getRealValues (self)
 
def getSimValues (self)
 

Public Attributes

 theComment
 
 theConstituents
 
 theDescription
 
 theMcVolume
 
 theName
 

Detailed Description

Definition at line 23 of file twikiExport.py.

Constructor & Destructor Documentation

def twikiExport.Material.__init__ (   self,
  matString,
  comment 
)

Definition at line 24 of file twikiExport.py.

References split.

24  def __init__(self, matString, comment):
25  if matString == "" or not matString[0] == "#":
26  raise Exception("not a valid material Definition: "+matString)
27  line = matString[1:]
28 
29  if len( line.split('"') ) < 5 or len( line.split('"')[4].split() ) < 2:
30  raise Exception("not a well formed Material Definition: "+matString)
31  self.theDescription = line.split('"')[1]
32  self.theName = line.split('"')[3]
33  self.theMcVolume = float(line.split('"')[4].split()[0])
34  self.theComment = comment
35  self.theConstituents = []
36 
def __init__(self, matString, comment)
Definition: twikiExport.py:24
double split
Definition: MVATrainer.cc:139

Member Function Documentation

def twikiExport.Material.__str__ (   self)
def twikiExport.Material.addConstituent (   self,
  constString,
  predefinedMaterials 
)

Definition at line 73 of file twikiExport.py.

References createfilelist.int, split, str, and twikiExport.Material.theConstituents.

73  def addConstituent(self, constString, predefinedMaterials):
74  if constString == "" or not constString[0] == "*":
75  raise Exception("not a valid Constituent: "+constString)
76  line = constString[1:]
77  self.theConstituents.append( Constituent(line, predefinedMaterials) )
78 
79  number = int( line.split('"')[0].split()[0] )
80  if not len(self.theConstituents) == number:
81  raise Exception("Constituent Number mismatch for "+str(len(self.theConstituents))+" in: "+line)
82 
def addConstituent(self, constString, predefinedMaterials)
Definition: twikiExport.py:73
#define str(s)
double split
Definition: MVATrainer.cc:139
def twikiExport.Material.getMass (   self)

Definition at line 67 of file twikiExport.py.

References twikiExport.Material.theConstituents.

Referenced by twikiExport.Material.getRealValues(), and twikiExport.Material.getSimValues().

67  def getMass(self):
68  result = 0
69  for con in self.theConstituents:
70  result += con.theMass * con.theCount
71  return result
72 
def twikiExport.Material.getRealValues (   self)

Definition at line 37 of file twikiExport.py.

References twikiExport.Material.getMass(), and twikiExport.Material.theConstituents.

Referenced by twikiExport.Material.getSimValues().

37  def getRealValues(self):
38  result = {}
39  result["Volume"] = 0
40  result["X0"] = 0
41  result["L0"] = 0
42 
43  totMass = self.getMass()
44  invX0 = 0
45  invL0 = 0
46  for con in self.theConstituents:
47  pWeight = con.theVolume * con.theDensity / totMass
48  invX0 += pWeight / con.theX0
49  invL0 += pWeight / con.theL0
50  result["Volume"] += con.theVolume
51  result["Density"] = self.getMass() / result["Volume"]
52  result["X0"] = 1 / ( invX0 * result["Density"] )
53  result["L0"] = 1 / ( invL0 * result["Density"] )
54 
55  return result
56 
def getRealValues(self)
Definition: twikiExport.py:37
def twikiExport.Material.getSimValues (   self)

Definition at line 57 of file twikiExport.py.

References twikiExport.Material.getMass(), twikiExport.Material.getRealValues(), and twikiExport.Material.theMcVolume.

57  def getSimValues(self):
58  result = self.getRealValues()
59  fraction = self.theMcVolume / result["Volume"]
60  result["Volume"] = self.theMcVolume
61  result["Density"] = self.getMass() / self.theMcVolume
62  result["X0"] *= fraction
63  result["L0"] *= fraction
64 
65  return result
66 
def getRealValues(self)
Definition: twikiExport.py:37
def getSimValues(self)
Definition: twikiExport.py:57

Member Data Documentation

twikiExport.Material.theComment

Definition at line 34 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().

twikiExport.Material.theConstituents
twikiExport.Material.theDescription

Definition at line 31 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().

twikiExport.Material.theMcVolume
twikiExport.Material.theName

Definition at line 32 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().