Ejemplo n.º 1
0
def readGeometry(input_file, layer, subdet):
    '''
    AUTHOR: Grasseau Gilles
    DESCRIPTION:
        This function reads the root file which contain the Geometry
    of the detector and create a dictionary of "Cell" object assiciated
    with every hexagonal cell in the detector.
    USAGE:
        INPUT:
            input_file  : the name of input geometry file (root file)
            Layer       : which layer's cell we are interested in
            Subdet      : which part of subdetector it is
                            (EE,...)
        OUTPUT:
            cells_d     : the hexagonal cell-dictionary with id of
                          cell as the key and Cell object as value
    '''
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file,
                          treename=treename,
                          subdet=subdet,
                          layer=layer,
                          wafer=-1)
    cells_d = dict([(c.id, c) for c in cells])
    t1 = datetime.datetime.now()
    print 'Cells read: number=', len(cells), ', time=', t1 - t0
    return cells_d
Ejemplo n.º 2
0
def readGeometry( input_file,  layer, subdet ):
    '''
    AUTHOR: Grasseau Gilles
    DESCRIPTION:
        This function reads the root file which contain the Geometry
    of the detector and create a dictionary of "Cell" object assiciated
    with every hexagonal cell in the detector.
    USAGE:
        INPUT:
            input_file  : the name of input geometry file (root file)
            Layer       : which layer's cell we are interested in
            Subdet      : which part of subdetector it is
                            (EE,...)
        OUTPUT:
            cells_d     : the hexagonal cell-dictionary with id of
                          cell as the key and Cell object as value
    '''
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file, treename=treename,
              subdet=subdet, layer=layer, wafer=-1)
    cells_d = dict([(c.id, c.center.coords[0]) for c in cells])
    t1 = datetime.datetime.now()
    print 'Cells read: number=', len(cells), ', time=', t1-t0
    return cells_d
Ejemplo n.º 3
0
def main(input_file, output_file, subdet):
    layers = [1]
    if subdet == 3: layers = [1, 28]
    elif subdet == 4: layers = [1, 12]
    # Read CMSSW geometry
    print 'Reading CMSSW geometry'
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells_dict = {}
    for layer in layers:
        print '> Layer', layer
        cs = read_geometry(filename=input_file,
                           treename=treename,
                           subdet=subdet,
                           layer=layer,
                           wafer=-1)
        for c in cs:
            if c.id not in cells_dict: cells_dict[c.id] = c
    cells = cells_dict.values()
    # Find max cell size
    max_size = max(
        map(
            lambda c: max([
                c.vertices.bounds[2] - c.vertices.bounds[0], c.vertices.bounds[
                    3] - c.vertices.bounds[1]
            ]), cells))
    print max_size
    # Find neighbors of each cell
    print 'Finding nearest neighbors'
    neighbor_indices, neighbor_ids = closest_neighbors(cells,
                                                       max_distance=max_size)

    # Save mapping
    pickle.dump(neighbor_ids, open(output_file, 'wb'))
Ejemplo n.º 4
0
def main(input_file, output_file, layer, subdet):
    # Read CMSSW geometry
    print 'Reading CMSSW geometry'
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file, treename=treename, subdet=subdet, layer=layer, wafer=-1)
    cells_dict = dict([(c.id, c) for c in cells])
    t1 = datetime.datetime.now()
    print '->', (t1-t0).seconds, 'seconds'
    # Produce Zoltan/Split trigger cells
    # 8" flat to flat distance is 164.9mm -> 190.41mm vertex to vertex 
    print 'Producing Zoltan/Split geometry'
    modules_out = module_grid(19.041, 192, grid_size=13, triggercell_size=2)
    cells_out = [cell for module in modules_out for cell in module]
    cells_out_dict = dict([(c.id, c) for c in cells])
    cells_out_module = dict([(cell.id,imod) for imod,module in enumerate(modules_out) for cell in module])
    # Find max output cell size
    max_size = max(map(lambda c:max([c.vertices.bounds[2]-c.vertices.bounds[0],c.vertices.bounds[3]-c.vertices.bounds[1]]), cells_out))
    t2 = datetime.datetime.now()
    print '->', (t2-t1).seconds, 'seconds'
    # Match CMSSW cells and Zoltan/Split trigger cells
    print 'Matching geometries'
    matched_indices, matched_ids = map_cells(cells, cells_out, max_distance=max_size)
    t3 = datetime.datetime.now()
    print '->', (t3-t2).seconds, 'seconds'

    # Save mapping
    pickle.dump(matched_ids, open(output_file, 'wb'))
Ejemplo n.º 5
0
def readGeometry( input_file,  layer, subdet ):
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file, treename=treename, 
              subdet=subdet, layer=layer, wafer=-1)
    cells_d = dict([(c.id, c) for c in cells])
    t1 = datetime.datetime.now()
    print 'Cells read: number=', len(cells), ', time=', t1-t0
    return cells_d
Ejemplo n.º 6
0
def readGeometry(input_file, layer, subdet):
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file,
                          treename=treename,
                          subdet=subdet,
                          layer=layer,
                          wafer=-1)
    cells_d = dict([(c.id, c) for c in cells])
    t1 = datetime.datetime.now()
    print 'Cells read: number=', len(cells), ', time=', t1 - t0
    return cells_d
Ejemplo n.º 7
0
def main(input_file, output_file, layer, subdet):
    # Read CMSSW geometry
    print 'Reading CMSSW geometry'
    t0 = datetime.datetime.now()
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells = read_geometry(filename=input_file,
                          treename=treename,
                          subdet=subdet,
                          layer=layer,
                          wafer=-1)
    cells_dict = dict([(c.id, c) for c in cells])
    t1 = datetime.datetime.now()
    print '->', (t1 - t0).seconds, 'seconds'
    # Produce Zoltan/Split trigger cells
    # 8" flat to flat distance is 164.9mm -> 190.41mm vertex to vertex
    print 'Producing Zoltan/Split geometry'
    modules_out = module_grid(19.041, 192, grid_size=13, triggercell_size=2)
    cells_out = [cell for module in modules_out for cell in module]
    cells_out_dict = dict([(c.id, c) for c in cells])
    cells_out_module = dict([(cell.id, imod)
                             for imod, module in enumerate(modules_out)
                             for cell in module])
    # Find max output cell size
    max_size = max(
        map(
            lambda c: max([
                c.vertices.bounds[2] - c.vertices.bounds[0], c.vertices.bounds[
                    3] - c.vertices.bounds[1]
            ]), cells_out))
    t2 = datetime.datetime.now()
    print '->', (t2 - t1).seconds, 'seconds'
    # Match CMSSW cells and Zoltan/Split trigger cells
    print 'Matching geometries'
    matched_indices, matched_ids = map_cells(cells,
                                             cells_out,
                                             max_distance=max_size)
    t3 = datetime.datetime.now()
    print '->', (t3 - t2).seconds, 'seconds'

    # Save mapping
    pickle.dump(matched_ids, open(output_file, 'wb'))
def main(input_file, output_file, subdet):
    layers = [1]
    if subdet==3: layers = [1,28] 
    elif subdet==4: layers = [1,12] 
    # Read CMSSW geometry
    print 'Reading CMSSW geometry'
    treename = 'hgcaltriggergeomtester/TreeCells'
    cells_dict = {}
    for layer in layers:
        print '> Layer', layer
        cs = read_geometry(filename=input_file, treename=treename, subdet=subdet, layer=layer, wafer=-1)
        for c in cs:
            if c.id not in cells_dict: cells_dict[c.id] = c
    cells = cells_dict.values()
    # Find max cell size
    max_size = max(map(lambda c:max([c.vertices.bounds[2]-c.vertices.bounds[0],c.vertices.bounds[3]-c.vertices.bounds[1]]), cells))
    print max_size
    # Find neighbors of each cell
    print 'Finding nearest neighbors'
    neighbor_indices, neighbor_ids = closest_neighbors(cells, max_distance=max_size)

    # Save mapping
    pickle.dump(neighbor_ids, open(output_file, 'wb'))