Пример #1
0
def write(outfile):
    print 'Writing to "%s"' % outfile
    fp = open(outfile, "w")
    from cowbells import geom
    fp.write(geom.dumps_json())
    fp.close()
    return
Пример #2
0
def generate_geometry_file(geofile=None, **params):
    from cowbells import geom, default

    default.all()  # fixme, move this into geom

    builder = get_builder(params["builder"], **params["builder_options"])
    geom.placements.PhysicalVolume("pvWorld", builder.top())
    builder.place()
    builder.sensitive()

    with open(geofile, "w") as fp:
        fp.write(geom.dumps_json())

    return geofile
Пример #3
0
def generate_geometry(connections, builder, geofile, sample = 'Water', **kwds):
    from cowbells import geom, default
    default.all()               # fixme, move this into geom

    exec ('import ' + builder)
    bmod = sys.modules[builder]
    bobj = bmod.Builder(sample=sample)

    geom.placements.PhysicalVolume('pvWorld', bobj.top())
    bobj.place()
    bobj.sensitive()

    with open(geofile,'w') as fp:
        fp.write(geom.dumps_json())

    return geofile
Пример #4
0
    def run(self):
        from cowbells import geom, default
        from cowbells.builder import nsrl

        default.all()

        b = nsrl.Builder()
        worldlv = b.top()
        geom.placements.PhysicalVolume('pvWorld',worldlv)    
        b.place()
        b.sensitive()

        print 'Writing %s' % self.p.outfile
        fp = open(self.p.outfile, 'w')
        fp.write(geom.dumps_json())
        fp.close()
        return 
Пример #5
0
def geometry(cfgfile, section, targets):
    from cowbells import geom, default

    default.all()

    cfg = ConfigParser.SafeConfigParser()
    cfg.read(cfgfile)

    bmodname = cfg.get(section, "builder")
    bmodoptsec = cfg.get(section, "builder_options")
    bmodargs = dict(cfg.items(bmodoptsec))

    exec ("import " + bmodname)
    bmod = sys.modules[bmodname]

    builder = bmod.Builder(**bmodargs)
    geom.placements.PhysicalVolume("pvWorld", builder.top())
    builder.place()
    builder.sensitive()

    with open(targets[0], "w") as fp:
        fp.write(geom.dumps_json())
Пример #6
0
    def run(self):
        from cowbells import geom, default
        from cowbells.builder import tubdet, world

        default.all()

        b = tubdet.World( tub = self.p.tub.capitalize(),
                          sample = self.p.sample.capitalize(),
                          inner_diameter = self.p.inner_diameter,
                          inner_height = self.p.inner_height,
                          reflectivity = self.p.reflectivity,
                          )

        worldlv = b.top()
        geom.placements.PhysicalVolume('pvWorld',worldlv)    
        b.place()
        b.sensitive()

        print 'Writing %s' % self.p.outfile
        fp = open(self.p.outfile, 'w')
        fp.write(geom.dumps_json())
        fp.close()
        return 
Пример #7
0
    def run(self):
        from cowbells import geom, default
        from cowbells.builder import boxdet, world

        default.all()

        b = boxdet.World( box = self.p.box.capitalize(),
                          sample = self.p.sample.capitalize(),
                          layout = self.p.layout,
                          period = float(self.p.period), ndets = int(self.p.ndets),
                          absorber_material = self.p.absorber_material,
                          absorber_thickness = float(self.p.absorber_thickness),
                          )
        
        worldlv = b.top()
        geom.placements.PhysicalVolume('pvWorld',worldlv)    
        b.place()
        b.sensitive()

        print 'Writing %s' % self.p.outfile
        fp = open(self.p.outfile, 'w')
        fp.write(geom.dumps_json())
        fp.close()
        return 
Пример #8
0
    def place_multi(self):
        p = self.pp()[0]
        print 'Multiple (%d) boxdets' % p.ndets
        world_lv = self.lvs[0]
        det_lv = self.lvs[1]
        abs_lv = self.lvs[2]

        for ndet in range(p.ndets):
            x_det = ndet*p.period
            if ndet:
                x_abs = x_det - 0.5*p.period
                name = abs_lv.name.replace('lv','pv',1)
                PhysicalVolume(name, abs_lv, world_lv, pos=[x_abs,0,0], copy=ndet)
            name = det_lv.name.replace('lv','pv',1)
            PhysicalVolume(name, det_lv, world_lv, pos=[x_det,0,0], copy=ndet+1)
                
        return

    def sensitive(self):
        for b in self.builders:
            b.sensitive()
        
            

if '__main__' == __name__:
    from cowbells import default, geom
    default.all()
    tdb = World()
    print geom.dumps_json()
Пример #9
0
def write(outfile):
    fp = open(outfile, "w")
    fp.write(geom.dumps_json())
    fp.close()