示例#1
0
 def register_particles(self, particles, side=0):
     '''
     Adds list of particles into the display
     @param particles:  list of particles to append to display
     @param side:  0 = left, 1 = right
     '''
     self.display.register(GTrajectories(particles), layer=2, sides=[side])
     if self.compare:
         otherside = (side + 1)%2 #opposite side
         self.display.register(GTrajectories(particles, is_grey=True), layer=1, sides=[otherside])
示例#2
0
 def process(self, event):
     particles = getattr(event, self.cfg_ana.particles)
     if self.is_display:
         self.display.clear()
         self.display.register(GTrajectories(particles), layer=1)
         for clustername in self.cfg_ana.clusters:
             blobs = map(Blob, getattr(event, clustername).values())
             self.display.register(blobs, layer=1, clearable=False)
示例#3
0
    def process(self, event):

        event.simulator = self
        if self.is_display:
            self.display.clear()
        pfsim_particles = []
        gen_particles = getattr(event, self.cfg_ana.gen_particles)
        try:
            self.simulator.simulate(gen_particles)
        except (PropagationError, SimulationError) as err:
            self.mainLogger.error(str(err) + ' -> Event discarded')
            return False
        pfsim_particles = self.simulator.ptcs
        if self.is_display:
            self.display.register(GTrajectories(pfsim_particles), layer=1)
        #these are the particles before simulation
        simparticles = sorted(pfsim_particles,
                              key=lambda ptc: ptc.e(),
                              reverse=True)
        setattr(event, self.simname, simparticles)

        #extract the tracks and clusters (extraction is prior to Colins merging step)
        event.tracks = dict()
        event.ecal_clusters = dict()
        event.hcal_clusters = dict()
        if "tracker" in self.simulator.pfinput.elements:
            for element in self.simulator.pfinput.elements["tracker"]:
                event.tracks[element.uniqueid] = element

        if "ecal_in" in self.simulator.pfinput.elements:
            for element in self.simulator.pfinput.elements["ecal_in"]:
                event.ecal_clusters[element.uniqueid] = element

        if "hcal_in" in self.simulator.pfinput.elements:
            for element in self.simulator.pfinput.elements["hcal_in"]:
                event.hcal_clusters[element.uniqueid] = element

        ruler = Distance()

        #create history node
        #note eventually history will be created by the simulator and passed in
        # as an argument and this will no longer be needed
        uniqueids = list(event.tracks.keys()) + list(
            event.ecal_clusters.keys()) + list(event.hcal_clusters.keys())
        history = dict((idt, Node(idt)) for idt in uniqueids)

        #Now merge the simulated clusters and tracks as a separate pre-stage (prior to new reconstruction)
        # and set the event to point to the merged cluster
        pfevent = PFEvent(event, 'tracks', 'ecal_clusters', 'hcal_clusters')
        merged_ecals = MergedClusterBuilder(pfevent.ecal_clusters, ruler,
                                            history)
        setattr(event, self.mergedecalsname, merged_ecals.merged)
        merged_hcals = MergedClusterBuilder(pfevent.hcal_clusters, ruler,
                                            merged_ecals.history_nodes)
        setattr(event, self.mergedhcalsname, merged_hcals.merged)
        setattr(event, self.historyname, merged_hcals.history_nodes)
示例#4
0
    from heppy.display.geometry import GDetector
    from heppy.display.pfobjects import GTrajectories

    display_on = True
    detector = cms

    logging.basicConfig(level='WARNING')
    logger = logging.getLogger('Simulator')
    logger.addHandler(logging.StreamHandler(sys.stdout))

    for i in range(1):
        if not i % 100:
            print i
        simulator = Simulator(detector, logger)
        # particles = monojet([211, -211, 130, 22, 22, 22], math.pi/2., math.pi/2., 2, 50)
        particles = [
            # particle(211, math.pi/2., math.pi/2., 100),
            particle(211, math.pi / 2 + 0.5, 0., 40.),
            # particle(130, math.pi/2., math.pi/2.+0., 100.),
            # particle(22, math.pi/2., math.pi/2.+0.0, 10.)
        ]
        simulator.simulate(particles)

    if display_on:
        display = Display(['xy', 'yz', 'ECAL_thetaphi', 'HCAL_thetaphi'])
        gdetector = GDetector(detector)
        display.register(gdetector, 0)
        gtrajectories = GTrajectories(simulator.ptcs)
        display.register(gtrajectories, 1)
        display.draw()