Пример #1
0
 def make_and_store_smeared_cluster(self,
                                    cluster,
                                    detector,
                                    accept=False,
                                    acceptance=None):
     '''Returns a copy of self with a smeared energy.
     If accept is False (default), returns None if the smeared
     cluster is not in the detector acceptance. '''
     eres = detector.energy_resolution(cluster.energy,
                                       cluster.position.Eta())
     response = detector.energy_response(cluster.energy,
                                         cluster.position.Eta())
     energy = cluster.energy * random.gauss(response, eres)
     clusters = self.smeared_cluster_collection(cluster.layer)
     smeared_cluster = SmearedCluster(cluster, energy, cluster.position,
                                      cluster.size(), cluster.layer,
                                      len(clusters), cluster.particle)
     pdebugger.info(str('Made {}'.format(smeared_cluster)))
     det = acceptance if acceptance else detector
     if det.acceptance(smeared_cluster) or accept:
         clusters[smeared_cluster.uniqueid] = smeared_cluster
         self.update_history(cluster.uniqueid, smeared_cluster.uniqueid)
         return smeared_cluster
     else:
         pdebugger.info(str('Rejected {}'.format(smeared_cluster)))
         return None
Пример #2
0
 def make_and_store_smeared_cluster(self, cluster, detector, accept=False, acceptance=None):
     '''Returns a copy of cluster, after a gaussian smearing of the energy.
     
     The smeared cluster is stored for further processing.
     
     @param cluster: the cluster to be smeared.
     @param detector: detector object from which the energy resolution, energy response
       and acceptance parametrizations are taken.
     @param accept: if set to true, always accept the cluster after smearing
     @param acceptance: optional detedctor object for acceptance.
       if provided, and if accept is False, used in place of detector.acceptance
     '''
     eres = detector.energy_resolution(cluster.energy, cluster.position.Eta())
     response = detector.energy_response(cluster.energy, cluster.position.Eta())
     energy = cluster.energy * random.gauss(response, eres)
     clusters = self.cluster_collection(cluster.layer, smeared=True)
     smeared_cluster = SmearedCluster(cluster,
                                      energy,
                                      cluster.position,
                                      cluster.size(),
                                      cluster.layer,
                                      len(clusters),
                                      cluster.particle)
     pdebugger.info(str('Made {}'.format(smeared_cluster)))
     det = acceptance if acceptance else detector
     if det.acceptance(smeared_cluster) or accept:
         clusters[smeared_cluster.uniqueid] = smeared_cluster                      
         self.update_history(cluster.uniqueid, smeared_cluster.uniqueid)            
         return smeared_cluster
     else:
         pdebugger.info(str('Rejected {}'.format(smeared_cluster)))
         return None
Пример #3
0
    def smear_cluster(self, cluster, detector, accept=False, acceptance=None):
        '''Returns a copy of self with a smeared energy.
        If accept is False (default), returns None if the smeared
        cluster is not in the detector acceptance. '''

        eres = detector.energy_resolution(cluster.energy,
                                          cluster.position.Eta())
        response = detector.energy_response(cluster.energy,
                                            cluster.position.Eta())
        energy = cluster.energy * random.gauss(response, eres)
        smeared_cluster = SmearedCluster(cluster, energy, cluster.position,
                                         cluster.size(), cluster.layer,
                                         cluster.particle)
        pdebugger.info(str('Made {}'.format(smeared_cluster)))
        det = acceptance if acceptance else detector
        if det.acceptance(smeared_cluster) or accept:
            return smeared_cluster
        else:
            pdebugger.info(str('Rejected {}'.format(smeared_cluster)))
            return None