def make_particles_from_block(self, block):
     ''' Take a block and use simple rules to construct particles 
     '''
     #take a block and find its parents (clusters and tracks)
     parents = block.element_uniqueids
     
     if  (len(parents) == 1) & (IdCoder.is_ecal(parents[0])):
         #print "make photon"
         self.make_photon(parents)
         
     elif ( (len(parents) == 2)  & (block.count_ecal() == 1 ) & (block.count_tracks() == 1)):
         #print "make hadron" 
         self.make_hadron(parents)
         
     elif  ((len(parents) == 3)  & (block.count_ecal() == 1) & (block.count_tracks() == 1) & (block.count_hcal() == 1)):
             #print "make hadron and photon"
             #probably not right but illustrates splitting of parents for more than one particle
             hparents = [] # will contain parents for the Hadron which gets everything except the 
                           #hcal which is used for the photom
             for elem in parents:
                 if (IdCoder.is_hcal(elem)):
                     self.make_photon({elem})
                 else :
                     hparents.append(elem)    
             self.make_hadron(hparents)
 
     else :
         pass
    def make_particles_from_block(self, block):
        ''' Take a block and use simple rules to construct particles 
        '''
        #take a block and find its parents (clusters and tracks)
        parents = block.element_uniqueids

        if (len(parents) == 1) & (IdCoder.is_ecal(parents[0])):
            #print "make photon"
            self.make_photon(parents)

        elif ((len(parents) == 2) & (block.count_ecal() == 1) &
              (block.count_tracks() == 1)):
            #print "make hadron"
            self.make_hadron(parents)

        elif ((len(parents) == 3) & (block.count_ecal() == 1) &
              (block.count_tracks() == 1) & (block.count_hcal() == 1)):
            #print "make hadron and photon"
            #probably not right but illustrates splitting of parents for more than one particle
            hparents = [
            ]  # will contain parents for the Hadron which gets everything except the
            #hcal which is used for the photom
            for elem in parents:
                if (IdCoder.is_hcal(elem)):
                    self.make_photon({elem})
                else:
                    hparents.append(elem)
            self.make_hadron(hparents)

        else:
            pass
Example #3
0
 def reconstruct_block(self, block):
     ''' see class description for summary of reconstruction approach
     '''
     uids = block.element_uniqueids #ids are already stored in sorted order inside block
     self.locked = dict( (uid, False) for uid in uids )
     # first reconstruct muons and electrons
     self.reconstruct_muons(block)
     self.reconstruct_electrons(block)
     # keeping only the elements that have not been used so far
     uids = [uid for uid in uids if not self.locked[uid]]
     if len(uids) == 1: #TODO WARNING!!! LOTS OF MISSING CASES
         uid = uids[0]
         parent_ids = [block.uniqueid, uid]
         if IdCoder.is_ecal(uid):
             self.reconstruct_cluster(self.papasevent.get_object(uid),
                                      "ecal_in", parent_ids)
         elif IdCoder.is_hcal(uid):
             self.reconstruct_cluster(self.papasevent.get_object(uid),
                                      "hcal_in", parent_ids)
         elif IdCoder.is_track(uid):
             self.reconstruct_track(self.papasevent.get_object(uid), 211,
                                    parent_ids)
             
     else: #TODO
         for uid in uids: #already sorted to have higher energy things first (see pfblock)
             if IdCoder.is_hcal(uid):
                 self.reconstruct_hcal(block, uid)
         for uid in uids: #already sorted to have higher energy things first
             if IdCoder.is_track(uid) and not self.locked[uid]:
             # unused tracks, so not linked to HCAL
             # reconstructing charged hadrons.
             # ELECTRONS TO BE DEALT WITH.
                 parent_ids = [block.uniqueid, uid]
                 self.reconstruct_track(self.papasevent.get_object(uid),
                                        211, parent_ids)
                 # tracks possibly linked to ecal->locking cluster
                 for idlink in block.linked_ids(uid, "ecal_track"):
                     #ask colin what happened to possible photons here:
                     self.locked[idlink] = True
                     #TODO add in extra photonsbut decide where they should go?
     self.unused.extend([uid for uid in block.element_uniqueids if not self.locked[uid]])       
Example #4
0
 def count_hcal(self):
     ''' Counts how many hcal cluster ids are in the block '''
     count = 0
     for elem in self.element_uniqueids:
         count += IdCoder.is_hcal(elem)
     return count
Example #5
0
 def count_hcal(self):
     ''' Counts how many hcal cluster ids are in the block '''
     count = 0
     for elem in self.element_uniqueids:
         count += IdCoder.is_hcal(elem)
     return count