~mbogomilov/maus/devel3

« back to all changes in this revision

Viewing changes to src/common_py/geometry/GDMLtoMAUSModule.py

  • Committer: Durga Rajaram
  • Date: 2013-11-19 02:09:06 UTC
  • mfrom: (659.1.77 rc)
  • Revision ID: durga@fnal.gov-20131119020906-t2vxx4h2yr0f09tj
Tags: MAUS-v0.7.4
MAUS-v0.7.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
CONFIGXSL = os.environ["MAUS_ROOT_DIR"] + \
23
23
        "/src/common_py/geometry/xsltScripts/ParentFileTranlsation.xsl"
24
 
ROTATEDXSL = os.environ["MAUS_ROOT_DIR"] + \
25
 
        "/src/common_py/geometry/xsltScripts/RotatedGeometryFileTranslation.xsl"
 
24
TRACKERXSL = os.environ["MAUS_ROOT_DIR"] + \
 
25
        "/src/common_py/geometry/xsltScripts/TrackerTranslation.xsl"
26
26
MM_XSL = os.environ["MAUS_ROOT_DIR"] + \
27
27
                         "/src/common_py/geometry/xsltScripts/MMTranslation.xsl"
28
28
 
51
51
        self.config_file = None
52
52
        self.material_file = None
53
53
        self.material_file_path = None
 
54
        self.tracker_file = None
54
55
        file_list = []
55
56
        self.step_files = file_list
56
57
        if os.path.exists(path) == False:
60
61
        gdmls = os.listdir(self.path)
61
62
        for fname in gdmls:
62
63
            if fname.find('materials') >= 0:
63
 
                found_file = self.path + '/' + fname
 
64
                found_file = os.path.join(self.path, fname)
64
65
                self.material_file = found_file
65
66
                self.material_file_path = os.path.abspath(self.material_file)
66
 
            if fname == 'fastradModel.gdml' or fname == 'FastradModel.gdml':
67
 
                found_file = self.path + '/' + fname
 
67
            if fname == 'fastradModel.gdml' or \
 
68
                   fname == 'FastradModel.gdml' or \
 
69
                   fname == 'Step_IV.gdml':
 
70
                found_file = os.path.join(self.path, fname)
68
71
                self.config_file = found_file
69
72
            if fname.find('Maus_Information') >= 0:
70
 
                found_file = self.path + '/' + fname
 
73
                found_file = os.path.join(self.path, fname)
71
74
                self.maus_information_file = found_file
 
75
            if fname == 'Tracker.gdml':
 
76
                found_file = os.path.join(self.path, fname)
 
77
                self.tracker_file = found_file
72
78
            if fname.find('materials') < 0 \
73
79
               and fname.find('fastrad') < 0 \
74
80
               and fname.find('Fastrad') < 0 \
75
81
               and fname.find('Maus_Information') < 0 \
76
82
               and fname.find('Beamline') < 0 \
77
 
               and fname[-5:] == '.gdml':
78
 
                stepfile = self.path + '/' + fname
 
83
               and fname[-5:] == '.gdml' \
 
84
               and fname.find('Step_IV') < 0\
 
85
               and fname.find('Tracker') < 0:
 
86
            
 
87
                stepfile = os.path.join(self.path, fname)
79
88
                self.step_files.append(stepfile)
 
89
                
80
90
 
81
91
    def convert_to_maus(self, output):
82
92
        """
94
104
            raise IOError('Output path doesnt exist '+str(output))
95
105
        else:
96
106
            outputfile1 = os.path.join(output, "ParentGeometryFile.dat")
97
 
            outputfile2 = os.path.join(output, "RotatedGeometryFile.dat")
 
107
            outputfile2 = os.path.join(output, "TrackerGeometryFile.dat")
 
108
            # outputfile3 = os.path.join(output, "RotatedGeometryFile.dat")
98
109
            config_file = CADImport(xmlin1 = str(self.config_file), \
99
110
                           xsl = str(CONFIGXSL), output = str(outputfile1))
100
111
            config_file.parse_xslt()
101
 
            rotated_file = CADImport(xmlin1 = str(self.config_file), \
102
 
                           xsl = str(ROTATEDXSL), output = str(outputfile2))
103
 
            rotated_file.parse_xslt()
 
112
            tracker_file = CADImport(xmlin1 = str(self.config_file), \
 
113
                           xsl = str(TRACKERXSL), output = str(outputfile2))
 
114
            tracker_file.parse_xslt()
 
115
            # rotated_file = CADImport(xmlin1 = str(self.config_file), \
 
116
            #                  xsl = str(ROTATEDXSL), output = str(outputfile3))
 
117
            # rotated_file.parse_xslt()                       
104
118
            print "Configuration File Converted"
105
119
            length = len(self.step_files)
106
120
            for num in range(0, length):