test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
twikiExport.Material Class Reference

Public Member Functions

def __init__
 
def __str__
 
def addConstituent
 
def getMass
 
def getRealValues
 
def getSimValues
 

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

Member Function Documentation

def twikiExport.Material.__str__ (   self)

Definition at line 83 of file twikiExport.py.

References twikiExport.Material.theComment, twikiExport.Constituent.theDescription, twikiExport.Material.theDescription, twikiExport.Material.theMcVolume, twikiExport.Constituent.theName, twikiExport.Material.theName, GeomDetType.theName, CocoaMaterialElementary.theName, RPCLinkSynchroStat::LinkBoard.theName, ALIFileOut.theName, HistoDef.theName, ALIFileIn.theName, FittedEntry.theName, Measurement.theName, CSCChamberSpecs.theName, and OpticalObject.theName.

83 
84  def __str__(self):
85  result = "[ "+self.theName+" Description: "+self.theDescription+" MC-Volume:"+str(self.theMcVolume)+"\n"
86  result += "Comments:\n"+self.theComment
87  return result
88 
#parses the .in File
def twikiExport.Material.addConstituent (   self,
  constString,
  predefinedMaterials 
)

Definition at line 73 of file twikiExport.py.

References split, and twikiExport.Material.theConstituents.

73 
74  def addConstituent(self, constString, predefinedMaterials):
75  if constString == "" or not constString[0] == "*":
76  raise StandardError , "not a valid Constituent: "+constString
77  line = constString[1:]
78  self.theConstituents.append( Constituent(line, predefinedMaterials) )
79 
80  number = int( line.split('"')[0].split()[0] )
81  if not len(self.theConstituents) == number:
82  raise StandardError, "Constituent Number mismatch for "+str(len(self.theConstituents))+" in: "+line
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 
68  def getMass(self):
69  result = 0
70  for con in self.theConstituents:
71  result += con.theMass * con.theCount
72  return result
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 
38  def getRealValues(self):
39  result = {}
40  result["Volume"] = 0
41  result["X0"] = 0
42  result["L0"] = 0
43 
44  totMass = self.getMass()
45  invX0 = 0
46  invL0 = 0
47  for con in self.theConstituents:
48  pWeight = con.theVolume * con.theDensity / totMass
49  invX0 += pWeight / con.theX0
50  invL0 += pWeight / con.theL0
51  result["Volume"] += con.theVolume
52  result["Density"] = self.getMass() / result["Volume"]
53  result["X0"] = 1 / ( invX0 * result["Density"] )
54  result["L0"] = 1 / ( invL0 * result["Density"] )
55 
56  return result
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 
58  def getSimValues(self):
59  result = self.getRealValues()
60  fraction = self.theMcVolume / result["Volume"]
61  result["Volume"] = self.theMcVolume
62  result["Density"] = self.getMass() / self.theMcVolume
63  result["X0"] *= fraction
64  result["L0"] *= fraction
65 
66  return result

Member Data Documentation

twikiExport.Material.theComment

Definition at line 34 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().

twikiExport.Material.theConstituents

Definition at line 35 of file twikiExport.py.

Referenced by twikiExport.Material.addConstituent(), twikiExport.Material.getMass(), and twikiExport.Material.getRealValues().

twikiExport.Material.theDescription

Definition at line 31 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().

twikiExport.Material.theMcVolume

Definition at line 33 of file twikiExport.py.

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

twikiExport.Material.theName

Definition at line 32 of file twikiExport.py.

Referenced by twikiExport.Material.__str__().