~cheid001/maus/Flip_Correction_Distro

« back to all changes in this revision

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

  • Committer: Adam Dobbs
  • Date: 2015-06-26 14:33:50 UTC
  • mfrom: (659.1.113 release-candidate)
  • Revision ID: phuccj@gmail.com-20150626143350-m56pbthi31ahqvxj
Tags: MAUS-v0.9.6
MAUS-v0.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
509
509
        Add the irises to the output gdml file
510
510
        """
511
511
        
512
 
        mausInfo = libxml2.parseFile(os.path.join(self.path_in, \
 
512
        mausInfo = libxml2.parseFile(os.path.join(self.path_out, \
 
513
                                                  self.maus_information_file))
 
514
        
 
515
        mausInfoIn = libxml2.parseFile(os.path.join(self.path_in, \
513
516
                                                  self.maus_information_file))
514
517
        runInfo = mausInfo.xpathEval(\
515
518
            "MICE_Information/Configuration_Information/run")
 
519
        print runInfo
516
520
        diffuserSetting = []
517
 
        if len(runInfo) > 0:
518
 
            diffuserSetting.append(runInfo.prop("diffusetThickness"))
 
521
        if len(runInfo) > 0: 
 
522
            diffuserSetting.append(runInfo[0].prop("diffuserThickness"))
 
523
            print "Will use diffuser setting ", diffuserSetting[0]
 
524
        else:
 
525
            print "Will use the default diffuser."
519
526
        # check the possible keys for suspected
520
 
        modulekeys = mausInfo.xpathEval(\
 
527
        modulekeys = mausInfoIn.xpathEval(\
521
528
            "MICE_Information/Other_Information/Module")
522
529
        keynode = next(x for x in \
523
530
                       modulekeys if x.prop('name').find('SolenoidUS') >= 0 \
551
558
            newNode = libxml2.newNode("physvol")
552
559
            fileNode = libxml2.newNode("file")
553
560
            if len(diffuserSetting) > 0: # test of whether the statement exists.
554
 
                print "Using diffuser setting ", diffuserSetting[0]
555
 
                if (inum == 1 and diffuserSetting[0] % 2 == 0) or \
556
 
                       (inum == 2 and (diffuserSetting[0] % 4 == 0 or \
557
 
                                     diffuserSetting[0] % 4 == 1)) or \
558
 
                       (inum == 3 and (diffuserSetting[0] < 4 or
559
 
                                     (diffuserSetting[0] >= 8 and \
560
 
                                      diffuserSetting[0] < 12))) or \
561
 
                       (inum == 4 and diffuserSetting[0] < 8):
 
561
                print "Using diffuser setting ", int(diffuserSetting[0])
 
562
                if (inum == 1 and int(diffuserSetting[0]) % 2 == 0) or \
 
563
                       (inum == 2 and (int(diffuserSetting[0]) % 4 == 0 or \
 
564
                                     int(diffuserSetting[0]) % 4 == 1)) or \
 
565
                       (inum == 3 and (int(diffuserSetting[0]) < 4 or
 
566
                                     (int(diffuserSetting[0]) >= 8 and \
 
567
                                      int(diffuserSetting[0]) < 12))) or \
 
568
                       (inum == 4 and int(diffuserSetting[0]) < 8):
562
569
                    newNode.setProp("name", "iris" + str(inum))
563
570
                    fileNode.setProp("name", "iris" + str(inum) + "_open.gdml")
564
571
                else:
584
591
            posNode.setProp("unit", posUnit)
585
592
            newNode.addChild(posNode)
586
593
            rotNode = libxml2.newNode("rotation")
587
 
            posNode.setProp("name", "rotRef_iris_"+str(inum))
 
594
            rotNode.setProp("name", "rotRef_iris_"+str(inum))
588
595
            rotNode.setProp("x", str(rot[0]))
589
596
            rotNode.setProp("y", str(rot[1]))
590
597
            rotNode.setProp("z", str(rot[2]))