예제 #1
0
    def construct(self, geom):

        ########################### Above is math, below is GGD ###########################

        materials.define_materials(geom)

        noRotate       = geom.structure.Rotation( 'noRotate',      '0deg',  '0deg',  '0deg'  )
        r90aboutX      = geom.structure.Rotation( 'r90aboutX',      '90deg',  '0deg',  '0deg'  )
        rminus90aboutX = geom.structure.Rotation( 'rminus90aboutX', '-90deg', '0deg',  '0deg'  )
        r90aboutY      = geom.structure.Rotation( 'r90aboutY',      '0deg',   '90deg', '0deg'  )
        r180aboutY     = geom.structure.Rotation( 'r180aboutY',     '0deg',   '180deg','0deg'  )
        rminus90aboutY = geom.structure.Rotation( 'rminus90aboutY', '0deg', '-90deg',  '0deg'  )
        r90aboutZ      = geom.structure.Rotation( 'r90aboutZ',      '0deg',   '0deg',  '90deg' )
        r90aboutXZ     = geom.structure.Rotation( 'r90aboutXZ', '90deg',  '0deg', '90deg'  )
        r90aboutYZ     = geom.structure.Rotation( 'r90aboutYZ', '0deg',  '90deg', '90deg'  )
        r90aboutXminusZ     = geom.structure.Rotation( 'r90aboutXminusZ', '-90deg',  '0deg', '90deg'  )
        r90aboutYminusZ     = geom.structure.Rotation( 'r90aboutYminusZ', '0deg',  '-90deg', '90deg'  )

        main_lv, main_hDim = ltools.main_lv( self, geom, "Box")
        self.add_volume(main_lv)

        # get Detector Enclosure and its logic volume
        de_sb = self.get_builder()
        de_lv = de_sb.get_volume()

        postemp = [Q('0m'),Q('0m'),Q('0m')]
        if self.DetEncPosition!=None:
            postemp=self.DetEncPosition
        detEnc_pos = geom.structure.Position(de_lv.name+'_pos', postemp[0], postemp[1], postemp[2])
        rot=[Q("0deg"),Q("0deg"),Q("0deg")]
        if self.DetEncRotation!=None:
            rot=self.DetEncRotation
        detEnc_rot = geom.structure.Rotation(de_lv.name+'_rot', rot[0], rot[1], rot[2])
        detEnc_pla = geom.structure.Placement(de_lv.name+'_pla', volume=de_lv, pos=detEnc_pos,rot=detEnc_rot)
        main_lv.placements.append(detEnc_pla.name)
예제 #2
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)

        builders = self.get_builders()
        second_lv = builders[0].get_volume()
        second_loc = self.Positions[0]
        third_lv = builders[1].get_volume()
        third_loc = self.Positions[1]

        third_pos = geom.structure.Position(third_lv.name + '_pos',
                                            third_loc[0], third_loc[1],
                                            third_loc[2])
        third_pla = geom.structure.Placement(third_lv.name + '_pla',
                                             volume=third_lv,
                                             pos=third_pos)
        second_lv.placements.append(third_pla.name)

        second_pos = geom.structure.Position(second_lv.name + '_pos',
                                             second_loc[0], second_loc[1],
                                             second_loc[2])
        second_pla = geom.structure.Placement(second_lv.name + '_pla',
                                              volume=second_lv,
                                              pos=second_pos)
        main_lv.placements.append(second_pla.name)
예제 #3
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        self.add_volume(main_lv)

        # definition local rotation
        rotation1 = geom.structure.Rotation(self.name + '_rot1',
                                            str(self.Rotation1[0]),
                                            str(self.Rotation1[1]),
                                            str(self.Rotation1[2]))

        # get sub-builders and its logic volume
        sb = self.get_builder()
        el_lv = sb.get_volume()

        # get the sub-builder dimension, using its shape
        el_shape = geom.store.shapes.get(el_lv.shape)
        el_dim = [el_shape.dx, el_shape.dy, el_shape.dz]

        # calculate half dimension of element plus the gap projected to the transportation vector
        sb_dim_v1 = [
            t * (d + 0.5 * self.InsideGap1)
            for t, d in zip(self.TranspV1, el_dim)
        ]
        sb_dim_v2 = [
            t * (d + 0.5 * self.InsideGap2)
            for t, d in zip(self.TranspV2, el_dim)
        ]

        # lower edge, the ule dimension projected on transportation vector
        low_end_v1 = [
            -t * d + ed
            for t, d, ed in zip(self.TranspV1, main_hDim, sb_dim_v1)
        ]
        low_end_v2 = [
            -t * d + ed
            for t, d, ed in zip(self.TranspV2, main_hDim, sb_dim_v2)
        ]

        for elem2 in xrange(self.NElements2):
            for elem1 in xrange(self.NElements1):
                # calculate the distance for n elements = i*2*halfdinemsion
                temp_v = [
                    elem1 * 2 * d1 + elem2 * 2 * d2
                    for d1, d2 in zip(sb_dim_v1, sb_dim_v2)
                ]
                # define the position for the element based on edge
                temp_v = [
                    te + l1 + l2
                    for te, l1, l2 in zip(temp_v, low_end_v1, low_end_v2)
                ]
                # defining position, placement, and finally insert into the ule.
                el_pos = geom.structure.Position(
                    self.name + "_el" + str(elem1) + '_' + str(elem2) + '_pos',
                    temp_v[0], temp_v[1], temp_v[2])
                el_pla = geom.structure.Placement(
                    self.name + "_el" + str(elem1) + '_' + str(elem2) + '_pla',
                    volume=el_lv,
                    pos=el_pos,
                    rot=rotation1)
                main_lv.placements.append(el_pla.name)
예제 #4
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)

        for i, sb in enumerate(self.get_builders()):
            Pos = [Q("0m"), Q("0m"), Q("0m")]
            Rot = [Q("0deg"), Q("0deg"), Q("0deg")]
            if self.Positions != None:
                Pos = self.Positions[i]
            if self.Rotations != None:
                Rot = self.Rotations[i]

            sb_lv = sb.get_volume()
            sb_pos = geom.structure.Position(sb_lv.name + '_pos', Pos[0],
                                             Pos[1], Pos[2])
            sb_rot = geom.structure.Rotation(sb_lv.name + '_rot', Rot[0],
                                             Rot[1], Rot[2])
            sb_pla = geom.structure.Placement(sb_lv.name + '_pla',
                                              volume=sb_lv,
                                              pos=sb_pos,
                                              rot=sb_rot)
            main_lv.placements.append(sb_pla.name)
예제 #5
0
    def construct( self, geom ):
        main_lv, main_hDim = ltools.main_lv( self, geom, "Box")
        self.add_volume( main_lv )

        # definition local rotation
        rotation = ltools.getRotation( self, geom )

        InsideGap = ltools.getInsideGap( self )

        if self.NElements != None:
            # get sub-builders and its logic volume
            sb = self.get_builder()
            sb_lv = sb.get_volume()
            sb_dim = ltools.getShapeDimensions( sb_lv, geom )

#            TranspV = [1,0,0] #MAK: not used

            # initial position, particular case
            pos = [-main_hDim[0]+sb_dim[0]*0.5, Q('0m'), Q('0m')]
            print( "STTPlane sb_dim[]= "+str(sb_dim))
            for elem in range(self.NElements):
                pos = [ sb_dim[0]*0.5+pos[0], pos[1]-math.pow(-1,elem+1)*sb_dim[0]*math.sqrt(3)*0.5, pos[2] ]
                sb_pos = geom.structure.Position(self.name+sb_lv.name+str(elem)+'_pos',
                                                    pos[0], pos[1], pos[2])
                sb_pla = geom.structure.Placement(self.name+sb_lv.name+str(elem)+'_pla',
                                                    volume=sb_lv, pos=sb_pos, rot =rotation)
                main_lv.placements.append(sb_pla.name)
                pos = [ sb_dim[0]*0.5+pos[0], pos[1]+math.pow(-1,elem+1)*sb_dim[0]*math.sqrt(3)*0.5, pos[2] ]
예제 #6
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv( self, geom, "Box")

        if self.AuxParams != None:
            ltools.addAuxParams( self, main_lv )

        self.add_volume( main_lv )


        TranspV = [0,0,1]
        begingap = ltools.getBeginGap( self )

        # initial position, based on the dimension projected on transportation vector
        pos = [Q('0m'),Q('0m'),-main_hDim[2]+begingap]

        for i,sb in enumerate(self.get_builders()):
            sb_lv = sb.get_volume()
            sb_dim = ltools.getShapeDimensions( sb_lv, geom )
            step = [Q('0cm'),Q('0cm'),Q('0cm')]
            #assert ( sb_dim != None ), " fail"
            if sb_dim != None:
                step[2] = sb_dim[2]
            else:
                assert( sb.halfDimension != None ), " No volumen defined on %s " % sb
                step[2] = sb.halfDimension['dz']
            pos[2] = pos[2] + step[2] + self.InsideGap[i]
            # defining position, placement, and finally insert into main logic volume.
            sb_pos = geom.structure.Position(self.name+sb_lv.name+'_pos_'+str(i),
                                                pos[0], pos[1], pos[2])
            sb_pla = geom.structure.Placement(self.name+sb_lv.name+'_pla_'+str(i),
                                                volume=sb_lv, pos=sb_pos )
            main_lv.placements.append(sb_pla.name)
            pos[2] = pos[2] + step[2]
예제 #7
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")

        TranspV = [0, 0, 1]
        if self.TranspV != None:
            TranspV = self.TranspV
            ltools.placeBooleanBuilders(self, geom, main_lv, TranspV)
예제 #8
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        self.add_volume(main_lv)

        builders = self.get_builders()
        sb_central = builders[0]
        sb_surr = builders[1]
        ltools.placeSurroundBuilders(main_lv, sb_central, sb_surr,
                                     self.InsideGap, geom)
예제 #9
0
    def construct(self, geom):
        """
        Construct the geometry for Generic Shape.
        :returns: None
        """
        main_lv, main_hDim = ltools.main_lv(self, geom, self.Shape)

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)
예제 #10
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        self.add_volume(main_lv)

        if self.NElements != None:
            TranspV = [1, 0, 0]
            if self.TranspV != None:
                TranspV = self.TranspV
            ltools.placeBuilders(self, geom, main_lv, TranspV)
        else:
            print("**Warning, no Elements to place inside " + self.name)
예제 #11
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        self.add_volume(main_lv)

        # definition local rotation
        rotation = geom.structure.Rotation(self.name + '_rot',
                                           str(self.Rotation[0]),
                                           str(self.Rotation[1]),
                                           str(self.Rotation[2]))

        # get sub-builders and its logic volume
        sb = self.get_builder()
        sb_lv = sb.get_volume()

        #top
        sbtop_pos = geom.structure.Position(
            self.name + sb_lv.name + '_top_pos', Q('0m'), Q('4m'), Q('5.2m'))
        sbtop_pla = geom.structure.Placement(self.name + sb_lv.name +
                                             '_top_pla',
                                             volume=sb_lv,
                                             pos=sbtop_pos,
                                             rot=rotation)
        main_lv.placements.append(sbtop_pla.name)

        #bottom
        sbbot_pos = geom.structure.Position(
            self.name + sb_lv.name + '_bot_pos', Q('0m'), Q('-4m'), Q('5.2m'))
        sbbot_pla = geom.structure.Placement(self.name + sb_lv.name +
                                             '_bot_pla',
                                             volume=sb_lv,
                                             pos=sbbot_pos,
                                             rot=rotation)
        main_lv.placements.append(sbbot_pla.name)

        #left
        sbleft_pos = geom.structure.Position(
            self.name + sb_lv.name + '_left_pos', Q('4m'), Q('0m'), Q('5.2m'))
        sbleft_pla = geom.structure.Placement(self.name + sb_lv.name +
                                              '_left_pla',
                                              volume=sb_lv,
                                              pos=sbleft_pos,
                                              rot=rotation)
        main_lv.placements.append(sbleft_pla.name)

        #right
        sbright_pos = geom.structure.Position(
            self.name + sb_lv.name + '_right_pos', Q('-4m'), Q('0m'),
            Q('5.2m'))
        sbright_pla = geom.structure.Placement(self.name + sb_lv.name +
                                               '_right_pla',
                                               volume=sb_lv,
                                               pos=sbright_pos,
                                               rot=rotation)
        main_lv.placements.append(sbright_pla.name)
예제 #12
0
    def construct(self, geom):
        """
        Construct the geometry for Rectangular Bar.
        :returns: None
        """
        main_lv, main_hDim = ltools.main_lv(self, geom, "Tubs")

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)
예제 #13
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)

        TranspV = [0, 0, 1]
        if self.TranspV != None:
            TranspV = self.TranspV
            ltools.placeUserLocationBuilders(self, geom, main_lv, TranspV)
예제 #14
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")

        if self.AuxParams != None:
            ltools.addAuxParams(self, main_lv)

        self.add_volume(main_lv)

        builders = self.get_builders()
        sb_central = builders[0]
        sb_top = builders[1]
        sb_side = builders[2]

        ltools.placeCrossBuilders(main_lv, sb_central, sb_top, sb_side, self,
                                  geom)
예제 #15
0
파일: KLOE.py 프로젝트: PPKoller/dunendggd
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        print("KLOEBuilder::construct()")
        print("main_lv = " + main_lv.name)
        self.add_volume(main_lv)
        self.build_yoke(main_lv, geom)
        self.build_solenoid(main_lv, geom)
        self.build_ecal(main_lv, geom)
        self.build_tracker(main_lv, geom)
        self.build_muon_system(main_lv, geom)
        print("printing main_lv: " + str(main_lv))

        #        TranspV = [0,0,1]
        #        begingap = ltools.getBeginGap( self )

        # initial position, based on the dimension projected on transportation vector

        #        pos = [Q('0m'),Q('0m'),-main_hDim[2]]
        pos = [Q('0m'), Q('0m'), Q('0m')]
예제 #16
0
    def construct(self, geom):
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        print("KLOEBuilder::construct()")
        print("main_lv = " + main_lv.name)
        self.add_volume(main_lv)
        self.build_yoke(main_lv, geom)
        self.build_solenoid(main_lv, geom)
        self.build_ecal(main_lv, geom)
        #self.build_muon_system(main_lv,geom)

        if (self.BuildGAR is True) or (self.BuildSTT is True):
            self.build_tracker(main_lv, geom)
        if (self.BuildSTTFULL is True):
            self.build_sttfull(main_lv, geom)
        if (self.Build3DST is True):
            self.build_3DST(main_lv, geom)
        if (self.Build3DSTwithSTT is True):
            self.build_3DSTwithSTT(main_lv, geom)

        print("printing main_lv: " + str(main_lv))
예제 #17
0
    def construct(self, geom):
        """
        Construct the geometry for Straw Tube Bar.
        :returns: None
        """
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        if isinstance(self.Sensitive, str):
            main_lv.params.append(("SensDet", self.Sensitive))
        self.add_volume(main_lv)

        copper_shape = geom.shapes.Tubs(self.name + "_copper",
                                        rmin=self.halfCopperDimension["rmin"],
                                        rmax=self.halfCopperDimension["rmax"],
                                        dz=self.halfCopperDimension["dz"])
        copper_lv = geom.structure.Volume(self.name + "_copper_lv",
                                          material="Copper",
                                          shape=copper_shape)

        copper_pla = geom.structure.Placement(self.name + "_copper_pla",
                                              volume=copper_lv)
        main_lv.placements.append(copper_pla.name)
예제 #18
0
    def construct( self, geom ):
        # main volume
        main_lv, main_hDim = ltools.main_lv( self, geom, "Box")
        print( "KLOESTT::construct()")
        print( "  main_lv = "+ main_lv.name)
        self.add_volume( main_lv )

        rot=[Q("0deg"),Q("0deg"),Q("0deg")]
        if self.modRot!=None:
            rot=self.modRot

        mod_builder=self.get_builder("STTModule")
        mod_lv=mod_builder.get_volume()
        # build modules starting from -z edge of KLOESTT
        # startingOffset moves us away from the edge (e.g., to center the array of modules in z)
        startz=-main_hDim[2]+self.startingOffset
        for imod in range(self.nModules):
            loc=[Q("0cm"),Q("0cm"),startz+(self.modWidth+self.gap)*(imod+0.5)]
            basename=self.name+'_'+mod_lv.name+'_'+str(imod)
            print( "Placing STTModule " + basename+" at "+str(loc))
            mod_pos=geom.structure.Position(basename+'_pos',loc[0],loc[1],loc[2])
            mod_rot=geom.structure.Rotation(basename+'_rot',rot[0],rot[1],rot[2])
            mod_pla=geom.structure.Placement(basename+'_pla',volume=mod_lv,pos=mod_pos,rot=mod_rot)
            main_lv.placements.append(mod_pla.name)
예제 #19
0
    def construct(self, geom):
        start_time = tm.time()

        main_lv, main_hDim = ltools.main_lv(self, geom, "Tubs")
        print("KLOESTTFULL::construct()")
        print("  main_lv = " + main_lv.name)
        self.add_volume(main_lv)

        # LAr target
        LAr_tgt_lv = self.construct_LAr_target(geom)
        LAr_tgt_pla = geom.structure.Placement("LAr_tgt_pla",
                                               volume=LAr_tgt_lv)
        main_lv.placements.append(LAr_tgt_pla.name)

        # 2 XY module after LAr target
        currentXPos = -self.kloeTrkRegRadius + self.LArThickness
        cos = 0.0
        halfHeight = 0.0

        for imod in range(self.nFrontST):
            currentXPos += imod * 2 * self.planeXXThickness
            cos = currentXPos / self.kloeTrkRegRadius
            halfHeight = self.kloeTrkRegRadius * math.sqrt(1 - cos * cos)
            name = "frontST" + str(imod)

            frontST_lv = self.construct_XYSTPlane(geom, name + "_vol",
                                                  halfHeight,
                                                  self.kloeTrkRegHalfDx,
                                                  "stGas_Ar19")
            frontST_pos = geom.structure.Position(
                name + "_pos", currentXPos + self.planeXXThickness, Q('0cm'),
                Q('0cm'))
            frontST_pla = geom.structure.Placement(name + "_pla",
                                                   volume=frontST_lv,
                                                   pos=frontST_pos)
            main_lv.placements.append(frontST_pla.name)

        currentXPos += 2 * self.planeXXThickness

        modBuilder = {
            'C3H6Mod': self.construct_C3H6_Module,
            'NoSlabMod': self.construct_NoSlab_Module,
            'CMod': self.construct_C_Module
        }

        for imod in range(self.nMod_Tot):
            name = "sttmod" + str(imod)

            if ((imod - 3) % 13 == 0):
                modThickness = self.CModThickness
                modType = 2
                construct_mod = modBuilder['CMod']
            elif (imod > 84):
                modThickness = self.NoSlabModThickness
                modType = 3
                construct_mod = modBuilder['NoSlabMod']
            else:
                modThickness = self.C3H6ModThickness
                modType = 1
                construct_mod = modBuilder['C3H6Mod']

            if (currentXPos + 0.5 * modThickness) < 0.0:
                cos = currentXPos / self.kloeTrkRegRadius
            else:
                cos = (currentXPos + modThickness) / self.kloeTrkRegRadius

            halfHeight = self.kloeTrkRegRadius * math.sqrt(1 - cos * cos)
            halfDimension = {
                'dx': modThickness / 2.0,
                'dy': halfHeight,
                'dz': self.kloeTrkRegHalfDx
            }

            mod_lv = construct_mod(geom, name, halfDimension)
            mod_pos = geom.structure.Position(name + "_pos",
                                              currentXPos + 0.5 * modThickness,
                                              Q('0cm'), Q('0cm'))
            mod_pla = geom.structure.Placement(name + "_pla",
                                               volume=mod_lv,
                                               pos=mod_pos)
            main_lv.placements.append(mod_pla.name)

            currentXPos += modThickness

        end_time = tm.time()
        elapsed_time = end_time - start_time
        print("elapsed time:" + str(elapsed_time))
예제 #20
0
    def construct(self, geom):

        mod_types = ["C3H6Mod", "C3H6Mod", "C3H6Mod"]
        for i in range(6):
            for j in range(13):
                if j == 0:
                    mod_types.append("CMod")
                else:
                    mod_types.append("C3H6Mod")
        mod_types.append("CMod")
        mod_types.append("C3H6Mod")
        mod_types.append("C3H6Mod")
        mod_types.append("C3H6Mod")
        mod_types.append("NoSlabMod")
        mod_types.append("NoSlabMod")
        mod_types.append("NoSlabMod")
        mod_types.append("NoSlabMod")
        mod_types.append("NoSlabMod")
        print(mod_types)
        modthicknesses = {
            "NoSlabMod": self.noSlabModThickness,
            "CMod": self.cModThickness,
            "C3H6Mod": self.C3H6ModThickness
        }

        ############################## the main tube    #######################################
        main_lv, main_hDim = ltools.main_lv(self, geom, "Tubs")
        print("KLOESTTFULL::construct()")
        print("  main_lv = " + main_lv.name)
        self.add_volume(main_lv)

        ########################################  liq Argon #################################
        self.construct_LAr_target(main_lv, geom)
        #####################################################################################

        pos_Slab_in_C3H6Mod = geom.structure.Position(
            "pos_Slab_in_C3H6Mod",
            -self.C3H6ModThickness / 2.0 + self.slabThickness / 2.0, "0cm",
            "0cm")
        pos_foilchunk_in_C3H6Mod = geom.structure.Position(
            "pos_foilchunk_in_C3H6Mod", -self.C3H6ModThickness / 2.0 +
            self.slabThickness + self.totfoilThickness / 2.0, "0cm", "0cm")
        pos_ST_in_C3H6Mod = geom.structure.Position(
            "pos_ST_in_C3H6Mod",
            self.C3H6ModThickness / 2.0 - self.planeXXThickness, "0cm", "0cm")
        pos_Graphite_in_Cmod = geom.structure.Position(
            "pos_Graphite_in_Cmod",
            -self.cModThickness / 2.0 + self.graphiteThickness / 2.0, "0cm",
            "0cm")
        pos_ST_in_Cmod = geom.structure.Position(
            "pos_ST_in_Cmod", self.cModThickness / 2.0 - self.planeXXThickness,
            "0cm", "0cm")
        pos_foilchunk_in_NoSlabMod = geom.structure.Position(
            "pos_foilchunk_in_NoSlabMod",
            -self.noSlabModThickness / 2.0 + self.totfoilThickness / 2.0,
            "0cm", "0cm")
        pos_ST_in_NoSlabMod = geom.structure.Position(
            "pos_ST_in_NoSlabMod",
            self.noSlabModThickness / 2.0 - self.planeXXThickness, "0cm",
            "0cm")
        pos_hh_in_ST = geom.structure.Position("pos_hh_in_ST",
                                               -self.planeXXThickness / 2.0,
                                               "0cm", "0cm")
        pos_vv_in_ST = geom.structure.Position("pos_vv_in_ST",
                                               self.planeXXThickness / 2.0,
                                               "0cm", "0cm")
        pos_straw2relative = geom.structure.Position(
            "pos_straw2relative", self.strawRadius * self.sqrt3,
            self.strawRadius, Q('0m'))

        self.fiveFoilPositions = []
        self.foilPositionsInFive = []
        for i in range(self.nfoil / 5):
            self.fiveFoilPositions.append(
                geom.structure.Position(
                    "pos_fiveFoilPositions_" + str(i),
                    -self.totfoilThickness / 2.0 +
                    self.fiveFoilThickness / 2.0 + i *
                    (self.fiveFoilThickness + self.foilGap), Q('0m'), Q('0m')))

        for i in range(5):
            self.foilPositionsInFive.append(
                geom.structure.Position("pos_foilInFive_" + str(i),
                                        (self.foilThickness + self.foilGap) *
                                        (i - 2), Q('0m'), Q('0m')))

        self.horizontalST_Xe = self.construct_strawtube(
            geom, "horizontalST_Xe", self.kloeTrkRegHalfDx, "C3H6Mod")
        self.horizontalST_Ar = self.construct_strawtube(
            geom, "horizontalST_Ar", self.kloeTrkRegHalfDx, "CMod")

        ########################################  Front ST  #################################
        usedLength = self.liqArThickness
        ratio = (self.kloeTrkRegRadius - usedLength) / self.kloeTrkRegRadius
        height = self.kloeTrkRegRadius * math.sqrt(1 - ratio * ratio)
        module_lv = self.construct_strawplane(
            geom, "frontST", height, "gra"
        )  # every time there is no raditor (with foils) we use Ar instead
        pos_frontST1 = geom.structure.Position(
            "pos_frontST1",
            -self.kloeTrkRegRadius + usedLength + self.planeXXThickness, "0cm",
            "0cm")
        pos_frontST2 = geom.structure.Position(
            "pos_frontST2",
            -self.kloeTrkRegRadius + usedLength + 3 * self.planeXXThickness,
            "0cm", "0cm")
        frontST_pla1 = geom.structure.Placement("pla_frontST1",
                                                volume=module_lv,
                                                pos=pos_frontST1,
                                                copynumber=0)
        frontST_pla2 = geom.structure.Placement("pla_frontST2",
                                                volume=module_lv,
                                                pos=pos_frontST2,
                                                copynumber=1)
        main_lv.placements.append(frontST_pla1.name)
        main_lv.placements.append(frontST_pla2.name)
        usedLength += self.frontStrawThickness
        #####################################################################################

        nModule = 1
        for imod in range(nModule):
            print("### imod ### ", imod)
            print("### type ### ", mod_types[imod])
            ModThickness = modthicknesses[mod_types[imod]]
            loc = [
                usedLength - self.kloeTrkRegRadius + 0.5 * ModThickness,
                Q("0cm"),
                Q("0cm")
            ]
            if (usedLength + 0.5 * ModThickness) < self.kloeTrkRegRadius:
                ratio = (self.kloeTrkRegRadius -
                         usedLength) / self.kloeTrkRegRadius
            else:
                ratio = (usedLength - self.kloeTrkRegRadius +
                         ModThickness) / self.kloeTrkRegRadius
            height = self.kloeTrkRegRadius * math.sqrt(1 - ratio * ratio)
            halfDimension = {
                'dx': ModThickness / 2.0,
                'dy': height,
                'dz': self.kloeTrkRegHalfDx
            }
            name = "STT_" + mod_types[imod] + "_" + str(imod)
            if mod_types[imod] == "NoSlabMod":
                module_lv = self.construct_noSlabModule(
                    geom, name, self.Material, halfDimension)
            elif mod_types[imod] == "CMod":
                module_lv = self.construct_cModule(geom, name, self.Material,
                                                   halfDimension)
            else:
                module_lv = self.construct_C3H6Module(geom, name,
                                                      self.Material,
                                                      halfDimension)
            module_pos = geom.structure.Position("pos_" + name, loc[0], loc[1],
                                                 loc[2])
            module_pla = geom.structure.Placement("pla_" + name,
                                                  volume=module_lv,
                                                  pos=module_pos,
                                                  copynumber=imod)
            main_lv.placements.append(module_pla.name)
            usedLength += ModThickness
#            print("%2d %8s %10.3f %10.3f"%(imod,mod_types[imod],(usedLength-ModThickness).magnitude,usedLength.magnitude))
        end_time = time.time()
        print("time diff:", end_time - self.start_time)
예제 #21
0
    def construct( self, geom ):
        # PARTICULAR GEOMETRY, IT IS NO GENERAL, NO EVERYONE CAN USE
        #(xyz- = xyzn, xyz+ = xyzp)
        main_lv, main_hDim = ltools.main_lv( self, geom, "Box")
        sb_boolean_shape = geom.store.shapes.get(main_lv.shape)
        builders = self.get_builders()

        #XY (-Z)
        sb_xyzn = builders[0]
        sb_xyzn_lv = sb_xyzn.get_volume()
        sb_xyzn_shape = geom.store.shapes.get(sb_xyzn_lv.shape)
        sb_pos = geom.structure.Position(self.name+'_pos_xyzn', Q('0cm'), Q('0cm'),
                                            -main_hDim[2]+sb_xyzn.halfDimension['dz'] )
        sb_boolean_shape = geom.shapes.Boolean( self.name+'_xyzn',
                                                type='intersection', first=sb_boolean_shape,
                                                second=sb_xyzn_shape, pos=sb_pos)

        #XY (+Z)
        sb_xyzp = builders[1]
        sb_xyzp_lv = sb_xyzp.get_volume()
        sb_xyzp_shape = geom.store.shapes.get(sb_xyzp_lv.shape)
        sb_pos = geom.structure.Position(self.name+'_pos_xyzp', Q('0cm'), Q('0cm'),
                                            main_hDim[2]-sb_xyzp.halfDimension['dz'] )
        sb_boolean_shape = geom.shapes.Boolean( self.name+'_xyzp',
                                                type='union', first=sb_boolean_shape,
                                                second=sb_xyzp_shape, pos=sb_pos)

        #YZ (-X)
        sb_yzxn = builders[2]
        sb_yzxn_lv = sb_yzxn.get_volume()
        sb_yzxn_shape = geom.store.shapes.get(sb_yzxn_lv.shape)
        sb_pos = geom.structure.Position(self.name+'_pos_yzxn', -main_hDim[0]+sb_yzxn.halfDimension['dx'],
                                        Q('0cm'), Q('0cm') )
        sb_boolean_shape = geom.shapes.Boolean( self.name+'_yzxn',
                                                type='union', first=sb_boolean_shape,
                                                second=sb_yzxn_shape, pos=sb_pos)

        #YZ (+X)
        sb_yzxp = builders[3]
        sb_yzxp_lv = sb_yzxp.get_volume()
        sb_yzxp_shape = geom.store.shapes.get(sb_yzxp_lv.shape)
        sb_pos = geom.structure.Position(self.name+'_pos_yzxp', +main_hDim[0]-sb_yzxp.halfDimension['dx'],
                                        Q('0cm'), Q('0cm') )
        sb_boolean_shape = geom.shapes.Boolean( self.name+'_yzxp',
                                                type='union', first=sb_boolean_shape,
                                                second=sb_yzxp_shape, pos=sb_pos)
        #XZ (-Y)
        sb_xzyn = builders[4]
        sb_xzyn_lv = sb_xzyn.get_volume()
        sb_xzyn_shape = geom.store.shapes.get(sb_xzyn_lv.shape)
        sb_pos = geom.structure.Position(self.name+'_pos_xzyn', Q('0cm'),
                                        -main_hDim[1]+sb_xzyn.halfDimension['dy']+Q('20cm'), Q('0cm') )
        sb_boolean_shape = geom.shapes.Boolean( self.name+'_xzyn',
                                                type='union', first=sb_boolean_shape,
                                                second=sb_xzyn_shape, pos=sb_pos)

        sb_boolean_lv = geom.structure.Volume('vol'+sb_boolean_shape.name, material=self.Material,
                                                shape=sb_boolean_shape)

        if isinstance(self.Sensitive,str):
            sb_boolean_lv.params.append(("SensDet",self.Sensitive))
        if isinstance(self.BField,str):
            sb_boolean_lv.params.append(("BField",self.BField))
        if isinstance(self.EField,str):
            sb_boolean_lv.params.append(("EField",self.EField))

        self.add_volume( sb_boolean_lv )
예제 #22
0
    def construct(self, geom):
        # main volume
        main_lv, main_hDim = ltools.main_lv(self, geom, "Box")
        print("STTModule::construct()")
        print("  main_lv = " + main_lv.name)
        self.add_volume(main_lv)

        # Straw Plane 1
        plane1_builder = self.get_builder("STTPlane1")
        print("plane1_builder=" + str(plane1_builder))
        plane1_lv = plane1_builder.get_volume()
        plane1_pos = geom.structure.Position(self.name + '_Plane1_pos',
                                             self.centerPlane1[0],
                                             self.centerPlane1[1],
                                             self.centerPlane1[2])
        plane1_rot = geom.structure.Rotation(self.name + '_Plane1_rot',
                                             self.rotationPlane1[0],
                                             self.rotationPlane1[1],
                                             self.rotationPlane1[2])
        plane1_pla = geom.structure.Placement(self.name + '_Plane1_pla',
                                              volume=plane1_lv,
                                              pos=plane1_pos,
                                              rot=plane1_rot)

        main_lv.placements.append(plane1_pla.name)

        # Straw Plane 2
        plane2_builder = self.get_builder("STTPlane2")
        print("plane2_builder=" + str(plane2_builder))
        plane2_lv = plane2_builder.get_volume()
        plane2_pos = geom.structure.Position(self.name + '_Plane2_pos',
                                             self.centerPlane2[0],
                                             self.centerPlane2[1],
                                             self.centerPlane2[2])
        plane2_rot = geom.structure.Rotation(self.name + '_Plane2_rot',
                                             self.rotationPlane2[0],
                                             self.rotationPlane2[1],
                                             self.rotationPlane2[2])
        plane2_pla = geom.structure.Placement(self.name + '_Plane2_pla',
                                              volume=plane2_lv,
                                              pos=plane2_pos,
                                              rot=plane2_rot)

        main_lv.placements.append(plane2_pla.name)

        # build the 4 radiators
        if self.radiators:
            # center of the radiator modules along y
            radiator_position = [
                [
                    self.centerPlane1[0],
                    self.centerPlane1[1] - self.radiatorOffset,
                    self.centerPlane1[2]
                ],
                [
                    self.centerPlane1[0],
                    self.centerPlane1[1] + self.radiatorOffset,
                    self.centerPlane1[2]
                ],
                [
                    self.centerPlane2[0],
                    self.centerPlane2[1] - self.radiatorOffset,
                    self.centerPlane2[2]
                ],
                [
                    self.centerPlane2[0],
                    self.centerPlane2[1] + self.radiatorOffset,
                    self.centerPlane2[2]
                ]
            ]
            radiator_rotation = [[
                self.rotationPlane1[0], self.rotationPlane1[1],
                self.rotationPlane1[2]
            ],
                                 [
                                     self.rotationPlane1[0],
                                     self.rotationPlane1[1],
                                     self.rotationPlane1[2]
                                 ],
                                 [
                                     self.rotationPlane2[0],
                                     self.rotationPlane2[1],
                                     self.rotationPlane2[2]
                                 ],
                                 [
                                     self.rotationPlane2[0],
                                     self.rotationPlane2[1],
                                     self.rotationPlane2[2]
                                 ]]
            radiator_hd = [
                self.radiator1HalfDimension, self.radiator1HalfDimension,
                self.radiator2HalfDimension, self.radiator2HalfDimension
            ]
            radiator_name = ['1A', '1B', '2A', '2B']
            for pos, rot, hd, rname in zip(radiator_position,
                                           radiator_rotation, radiator_hd,
                                           radiator_name):
                basename = 'STTModule_Radiator_' + rname
                rad_shape = geom.shapes.Box(basename, hd[0], hd[1], hd[2])
                rad_lv = geom.structure.Volume(basename + "_vol",
                                               material="RadiatorBlend",
                                               shape=rad_shape)
                rad_pos = geom.structure.Position(basename + "_pos", pos[0],
                                                  pos[1], pos[2])
                rad_rot = geom.structure.Rotation(basename + "_rot", rot[0],
                                                  rot[1], rot[2])
                rad_pla = geom.structure.Placement(basename + "_pla",
                                                   volume=rad_lv,
                                                   pos=rad_pos,
                                                   rot=rad_rot)
                main_lv.placements.append(rad_pla.name)
예제 #23
0
    def construct(self, geom):
        """ Construct the geometry.

        The standard geometry consists of a cylindrical vessel
        filled with gas. Two TPC sensitive volumes are placed
        within the gas, as is a central electrode.
        After that, a readout plane and field cage are added
        to each TPC.

        args:
            geom: The geometry

        """

        # If using a custom gas, define here
        if self.Composition is not None:
            geom.matter.Mixture(self.GasType,
                                density=self.GasDensity,
                                components=self.Composition)

        main_lv, main_hDim = ltools.main_lv(self, geom, 'Tubs')
        print('GasTPCBuilder::construct()')
        print('main_lv = ' + main_lv.name)
        self.add_volume(main_lv)

        # Construct the chamber
        tpc_chamber_shape = geom.shapes.Tubs('TPCChamber',
                                             rmax=self.ChamberRadius,
                                             dz=self.ChamberLength * 0.5)
        tpc_chamber_lv = geom.structure.Volume('volTPCChamber',
                                               material=self.ChamberMaterial,
                                               shape=tpc_chamber_shape)

        if self.BField is not None:
            tpc_chamber_lv.params.append(('BField', self.BField))
        # Place into main LV
        pos = [Q('0m'), Q('0m'), Q('0m')]
        tpc_chamber_pos = geom.structure.Position('TPCChamber_pos', pos[0],
                                                  pos[1], pos[2])
        tpc_chamber_pla = geom.structure.Placement('TPCChamber_pla',
                                                   volume=tpc_chamber_lv,
                                                   pos=tpc_chamber_pos)
        main_lv.placements.append(tpc_chamber_pla.name)

        # Add in the gas volume
        tpc_gas_shape = geom.shapes.Tubs(
            'TPCGas',
            rmax=self.ChamberRadius - self.WallThickness,
            dz=0.5 * self.ChamberLength - self.EndCapThickness)

        tpc_gas_lv = geom.structure.Volume('volTPCGas',
                                           material=self.GasType,
                                           shape=tpc_gas_shape)

        # Place gas into the chamber
        pos = [Q('0m'), Q('0m'), Q('0m')]
        tpc_gas_pos = geom.structure.Position('TPCGas_pos', pos[0], pos[1],
                                              pos[2])
        tpc_gas_pla = geom.structure.Placement('TPCGas_pla',
                                               volume=tpc_gas_lv,
                                               pos=tpc_gas_pos)
        tpc_chamber_lv.placements.append(tpc_gas_pla.name)

        # Construct the TPCs
        if not self.BuildEmpty:
            self.construct_tpcs(geom, tpc_gas_lv)
예제 #24
0
    def construct(self, geom):
        #  liqAR STXXYY STXXYY ||||| 3+ 1+ 12 + 1 + 12 + 1 + 12 + 1 + 12+ 1 + 12+ 1 + 12 + 1 + 3  |||| 5 no_slab modules
        sqrt3 = 1.7320508
        kloeTrkRegRadius = self.kloeVesselRadius - self.extRadialgap
        kloeTrkRegHalfDx = self.kloeVesselHalfDx - self.extLateralgap
        planeXXThickness = self.strawRadius * (2 + sqrt3)
        totfoilThickness = self.nfoil * self.foilThickness + (self.nfoil -
                                                              1) * self.foilGap
        regModThickness = planeXXThickness * 2 + totfoilThickness + self.slabThickness

        cModThickness = planeXXThickness * 2 + self.graphiteThickness
        noSlabModThickness = planeXXThickness * 2 + totfoilThickness

        self.planeXXThickness = planeXXThickness
        self.totfoilThickness = totfoilThickness
        self.kloeTrkRegHalfDx = kloeTrkRegHalfDx
        self.kloeTrkRegRadius = kloeTrkRegRadius
        self.pureSTModThickness = planeXXThickness * 4
        self.SingleSTModThickness = planeXXThickness * 2
        self.regModThickness = regModThickness
        self.noSlabModThickness = noSlabModThickness

        test_nfront = (kloeTrkRegRadius - self.Depth3DST / 2 -
                       self.offset3DSTcenter) / (self.pureSTModThickness +
                                                 self.pureSTModGap)
        test_nMid = self.Depth3DST / (self.pureSTModThickness +
                                      self.pureSTModGap)
        test_nRear2 = kloeTrkRegRadius - self.Depth3DST / 2 + self.offset3DSTcenter - (
            self.pureSTModThickness + self.pureSTModGap
        ) * self.nRear1Mod - self.noSlabModThickness * self.nRear3Mod
        test_nRear2A = test_nRear2 / self.regModThickness
        test_nRear2B = test_nRear2 / self.noSlabModThickness
        print("test_nfront:", test_nfront)
        print("test_nMid:", test_nMid)
        print("test_nRear2A:", test_nRear2A)
        print("test_nRear2B:", test_nRear2B)

        self.frontGap = kloeTrkRegRadius - (
            self.pureSTModThickness + self.pureSTModGap
        ) * self.nFrontMod - self.Depth3DST / 2 - self.offset3DSTcenter
        print("front gap:", self.frontGap)

        rearModsWidth = (
            self.pureSTModThickness + self.pureSTModGap
        ) * self.nRear1Mod + self.regModThickness * self.nRear2Mod + self.noSlabModThickness * self.nRear3Mod
        self.rearGap = kloeTrkRegRadius - self.Depth3DST / 2 + self.offset3DSTcenter - rearModsWidth
        print("rearModsWidth:", rearModsWidth)
        print("self.rearGap:", self.rearGap)

        print("totfoilThickness:", totfoilThickness)
        print("self.slabThickness:", self.slabThickness)
        print("planeXXThickness:", planeXXThickness)
        print("regModThickness:", regModThickness)
        print("cModThickness:", cModThickness)
        print("noSlabModThickness:", noSlabModThickness)

        main_lv, main_hDim = ltools.main_lv(self, geom, "Tubs")
        self.add_volume(main_lv)

        #        testShape = geom.shapes.Tubs("testShape", rmin=Q("2m"), rmax = Q("2.05m"), dz = self.kloeTrkRegHalfDx)
        #        testlv    = geom.structure.Volume("testlv", material="Tungsten", shape=testShape)
        #        testpla = geom.structure.Placement("pla_test", volume=testlv)
        #        main_lv.placements.append(testpla.name)

        pos_Slab_in_RegMod = geom.structure.Position(
            "pos_Slab_in_RegMod",
            -regModThickness / 2.0 + self.slabThickness / 2.0, "0cm", "0cm")
        pos_foilchunk_in_RegMod = geom.structure.Position(
            "pos_foilchunk_in_RegMod", -regModThickness / 2.0 +
            self.slabThickness + self.totfoilThickness / 2.0, "0cm", "0cm")
        pos_ST_in_RegMod = geom.structure.Position(
            "pos_ST_in_RegMod", regModThickness / 2.0 - planeXXThickness,
            "0cm", "0cm")
        pos_Graphite_in_Cmod = geom.structure.Position(
            "pos_Graphite_in_Cmod",
            -cModThickness / 2.0 + self.graphiteThickness / 2.0, "0cm", "0cm")
        pos_ST_in_Cmod = geom.structure.Position(
            "pos_ST_in_Cmod", cModThickness / 2.0 - planeXXThickness, "0cm",
            "0cm")
        pos_foilchunk_in_NoSlabMod = geom.structure.Position(
            "pos_foilchunk_in_NoSlabMod",
            -noSlabModThickness / 2.0 + self.totfoilThickness / 2.0, "0cm",
            "0cm")
        pos_ST_in_NoSlabMod = geom.structure.Position(
            "pos_ST_in_NoSlabMod", noSlabModThickness / 2.0 - planeXXThickness,
            "0cm", "0cm")
        pos_hh_in_ST = geom.structure.Position("pos_hh_in_ST",
                                               -self.planeXXThickness / 2.0,
                                               "0cm", "0cm")
        pos_vv_in_ST = geom.structure.Position("pos_vv_in_ST",
                                               self.planeXXThickness / 2.0,
                                               "0cm", "0cm")
        pos_hh1_in_doubleST = geom.structure.Position(
            "pos_hh1_in_doubleST", -self.planeXXThickness / 2.0 * 3, "0cm",
            "0cm")
        pos_vv1_in_doubleST = geom.structure.Position(
            "pos_vv1_in_doubleST", -self.planeXXThickness / 2.0, "0cm", "0cm")
        pos_hh2_in_doubleST = geom.structure.Position(
            "pos_hh2_in_doubleST", self.planeXXThickness / 2.0, "0cm", "0cm")
        pos_vv2_in_doubleST = geom.structure.Position(
            "pos_vv2_in_doubleST", self.planeXXThickness / 2.0 * 3, "0cm",
            "0cm")
        pos_oneSrawDown = geom.structure.Position("pos_oneSrawDown", "0cm",
                                                  -self.strawRadius * 2, "0cm")

        self.foilpositions = []
        for i in range(self.nfoil):
            self.foilpositions.append(
                geom.structure.Position(
                    "pos_foilpositions_" + str(i),
                    -self.totfoilThickness / 2.0 + self.foilThickness / 2.0 +
                    i * (self.foilThickness + self.foilGap), Q('0m'), Q('0m')))

        self.horizontalST_Xe = self.construct_strawtube(
            geom, "horizontalST_Xe", kloeTrkRegHalfDx, "reg")
        self.horizontalST_Ar = self.construct_strawtube(
            geom, "horizontalST_Ar", kloeTrkRegHalfDx, "gra")

        ############################ build front STT
        self.build_frontSTT(geom, main_lv)

        ############################ build top & bottom & side  STT
        self.build_TopBotSTT(geom, main_lv)
        self.build_sideSTT(geom, main_lv)

        ############################ build rear STT
        self.build_rearSTT(geom, main_lv)

        ########################### build 3DST
        self.build_3DST(geom, main_lv)