def __init__(self, name, daughter, mother=None, rot=None, pos=None, copy=0): if isinstance(daughter, volumes.LogicalVolume): daughter = daughter.name assert volumes.get(daughter), 'No daughter volume "%s"' % daughter if mother: if isinstance(mother, volumes.LogicalVolume): mother = mother.name assert volumes.get(mother), 'No mother volume "%s"' % mother self.__dict__=dict(name=name, daughter=daughter, mother=mother, rot=rot, pos=pos, copy=copy) store.append(self) return
def walk(top): ''' Iterate through the physical volume hierarchy. Returns a sequence of [pvs],lv where [pvs] is a list of parent PhysicalVolume objects and lv is a daughter LogicalVolume object. Elements are PhysicalVolume objects ''' for pv in get(top): pvs = placed(pv.daughter) yield [pv],volumes.get(pv.daughter) for daughter_pv in pvs: for ps,l in walk(daughter_pv): yield [pv]+ps,volumes.get(l) continue continue return
def placed(lv): ''' Return all PhysicalVolumes objects placed into the mother lv. ''' lv = volumes.get(lv) ret = [] for pv in store: if pv.mother == lv.name: ret.append(pv) return ret
def __init__(self, name, hcname, logvol, world_pv = None): ''' Describe a sensitive detector associated with the named hitcollection and logical volume. If world_pv is None it is assumed to be the first one in placements.store. ''' if isinstance(logvol, volumes.LogicalVolume): logvol = logvol.name assert volumes.get(logvol), 'No such logical volume: %s' % logvol if not world_pv: world_pv = placements.store[0].name self.__dict__ = dict(name=name, hcname=hcname, logvol=logvol, world_pv=world_pv) store.append(self) return