示例#1
0
 def reconstruct_track(
     self,
     track,
     pdgid,
     parent_ids,
     clusters=None
 ):  # cluster argument does not ever seem to be used at present
     '''construct a charged hadron from the track
     '''
     if self.locked[track.uniqueid]:
         return
     vertex = track.path.points['vertex']
     pdgid = pdgid * track.charge
     mass, charge = particle_data[pdgid]
     p4 = TLorentzVector()
     p4.SetVectM(track.p3(), mass)
     particle = Particle(p4,
                         vertex,
                         charge,
                         pdgid,
                         len(self.particles),
                         subtype='r')
     #todo fix this so it picks up smeared track points (need to propagagte smeared track)
     particle.set_track(
         track)  #refer to existing track rather than make a new one
     self.locked[track.uniqueid] = True
     pdebugger.info(str('Made {} from {}'.format(particle, track)))
     self.insert_particle(parent_ids, particle)
     return particle
示例#2
0
 def reconstruct_cluster(self, cluster, layer, energy=None, vertex=None):
     if vertex is None:
         vertex = TVector3()
     pdg_id = None
     if layer=='ecal_in':
         pdg_id = 22
     elif layer=='hcal_in':
         pdg_id = 130
     else:
         raise ValueError('layer must be equal to ecal_in or hcal_in')
     assert(pdg_id)
     mass, charge = particle_data[pdg_id]
     if energy is None:
         energy = cluster.energy
     if energy < mass: 
         return None 
     momentum = math.sqrt(energy**2 - mass**2)
     p3 = cluster.position.Unit() * momentum
     p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(), energy)
     particle = Particle(p4, vertex, charge, pdg_id)
     path = StraightLine(p4, vertex)
     path.points[layer] = cluster.position
     particle.set_path(path)
     particle.clusters[layer] = cluster
     cluster.locked = True
     return particle
示例#3
0
 def reconstruct_cluster(self, cluster, layer, energy = None, vertex = None):
     '''construct a photon if it is an ecal
        construct a neutral hadron if it is an hcal
     '''        
     if vertex is None:
         vertex = TVector3()
     pdg_id = None
     if layer=='ecal_in':
         pdg_id = 22 #photon
     elif layer=='hcal_in':
         pdg_id = 130 #K0
     else:
         raise ValueError('layer must be equal to ecal_in or hcal_in')
     assert(pdg_id)
     mass, charge = particle_data[pdg_id]
     if energy is None:
         energy = cluster.energy
     if energy < mass: 
         return None 
     if (mass==0):
         momentum= energy #avoid sqrt for zero mass
     else:
         momentum = math.sqrt(energy**2 - mass**2)
     p3 = cluster.position.Unit() * momentum
     p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(), energy) #mass is not accurate here
     particle = Particle(p4, vertex, charge, pdg_id, Identifier.PFOBJECTTYPE.RECPARTICLE)
     path = StraightLine(p4, vertex)
     path.points[layer] = cluster.position #alice: this may be a bit strange because we can make a photon with a path where the point is actually that of the hcal?
                                         # nb this only is problem if the cluster and the assigned layer are different
     particle.set_path(path)
     particle.clusters[layer] = cluster  # not sure about this either when hcal is used to make an ecal cluster?
     self.locked[cluster.uniqueid] = True #just OK but not nice if hcal used to make ecal.
     pdebugger.info(str('Made {} from {}'.format(particle,  cluster)))
     return particle
示例#4
0
 def reconstruct_cluster(self,
                         cluster,
                         layer,
                         parent_ids,
                         energy=None,
                         vertex=None):
     '''construct a photon if it is an ecal
        construct a neutral hadron if it is an hcal
     '''
     if self.locked[cluster.uniqueid]:
         return
     if vertex is None:
         vertex = TVector3()
     pdg_id = None
     propagate_to = None
     if layer == 'ecal_in':
         pdg_id = 22  #photon
         propagate_to = [self.detector.elements['ecal'].volume.inner]
     elif layer == 'hcal_in':
         pdg_id = 130  #K0
         propagate_to = [
             self.detector.elements['ecal'].volume.inner,
             self.detector.elements['hcal'].volume.inner
         ]
     else:
         raise ValueError('layer must be equal to ecal_in or hcal_in')
     assert (pdg_id)
     mass, charge = particle_data[pdg_id]
     if energy is None:
         energy = cluster.energy
     if energy < mass:
         return None
     if mass == 0:
         momentum = energy  #avoid sqrt for zero mass
     else:
         momentum = math.sqrt(energy**2 - mass**2)
     p3 = cluster.position.Unit() * momentum
     p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(),
                         energy)  #mass is not accurate here
     particle = Particle(p4,
                         vertex,
                         charge,
                         pdg_id,
                         len(self.particles),
                         subtype='r')
     # alice: this may be a bit strange because we can make a photon
     # with a path where the point is actually that of the hcal?
     # nb this only is problem if the cluster and the assigned layer
     # are different
     propagator(charge).propagate([particle], propagate_to)
     #merge Nov 10th 2016 not sure about following line (was commented out in papasevent branch)
     particle.clusters[
         layer] = cluster  # not sure about this either when hcal is used to make an ecal cluster?
     self.locked[
         cluster.
         uniqueid] = True  #just OK but not nice if hcal used to make ecal.
     pdebugger.info(str('Made {} from {}'.format(particle, cluster)))
     self.insert_particle(parent_ids, particle)
示例#5
0
文件: PapasSim.py 项目: rsawada/heppy
 def simparticle(ptc, index):
     '''Create a sim particle to be used in papas from an input particle.
     '''
     tp4 = ptc.p4()
     vertex = ptc.start_vertex().position()
     charge = ptc.q()
     pid = ptc.pdgid()
     simptc = Particle(tp4, vertex, charge, index, pid)
     pdebugger.info(" ".join(("Made", simptc.__str__())))
     simptc.gen_ptc = ptc
     return simptc
示例#6
0
 def reconstruct_track(self, track, clusters=None):
     vertex = track.path.points['vertex']
     pdg_id = 211 * track.charge
     mass, charge = particle_data[pdg_id]
     p4 = TLorentzVector()
     p4.SetVectM(track.p3, mass)
     particle = Particle(p4, vertex, charge, pdg_id)
     particle.set_path(track.path)
     particle.clusters = clusters
     track.locked = True
     return particle
示例#7
0
def pfsimparticle(ptc):
    '''Create a PFSimParticle from a particle.
    The PFSimParticle will have the same p4, vertex, charge, pdg ID.
    '''
    tp4 = ptc.p4()
    vertex = ptc.start_vertex().position()
    charge = ptc.q()
    pid = ptc.pdgid()
    simptc = PFSimParticle(tp4, vertex, charge, pid)
    pdebugger.info(" ".join(("Made", simptc.__str__())))
    simptc.gen_ptc = ptc
    return simptc
示例#8
0
def pfsimparticle(ptc):
    """Create a PFSimParticle from a particle.
    The PFSimParticle will have the same p4, vertex, charge, pdg ID.
    """
    tp4 = ptc.p4()
    vertex = ptc.start_vertex().position()
    charge = ptc.q()
    pid = ptc.pdgid()
    simptc = PFSimParticle(tp4, vertex, charge, pid)
    pdebugger.info(" ".join(("Made", simptc.__str__())))
    simptc.gen_ptc = ptc
    return simptc
示例#9
0
 def reconstruct_track(self, track, clusters=None):  # cluster argument does not ever seem to be used at present
     """construct a charged hadron from the track
     """
     vertex = track.path.points["vertex"]
     pdg_id = 211 * track.charge
     mass, charge = particle_data[pdg_id]
     p4 = TLorentzVector()
     p4.SetVectM(track.p3, mass)
     particle = Particle(p4, vertex, charge, pdg_id, Identifier.PFOBJECTTYPE.RECPARTICLE)
     particle.set_path(track.path)
     particle.clusters = clusters
     self.locked[track.uniqueid] = True
     pdebugger.info(str("Made {} from {}".format(particle, track)))
     return particle
示例#10
0
 def reconstruct_track(self, track, clusters = None): # cluster argument does not ever seem to be used at present
     '''construct a charged hadron from the track
     '''
     vertex = track.path.points['vertex']
     pdg_id = 211 * track.charge
     mass, charge = particle_data[pdg_id]
     p4 = TLorentzVector()
     p4.SetVectM(track.p3, mass)
     particle = Particle(p4, vertex, charge, pdg_id, Identifier.PFOBJECTTYPE.RECPARTICLE)
     particle.set_path(track.path)
     particle.clusters = clusters
     self.locked[track.uniqueid] = True
     pdebugger.info(str('Made {} from {}'.format(particle,  track)))
     return particle
示例#11
0
 def reconstruct_cluster(self, cluster, layer, parent_ids,
                         energy=None, vertex=None):
     '''construct a photon if it is an ecal
        construct a neutral hadron if it is an hcal
     '''
     if self.locked[cluster.uniqueid]:
         return 
     if vertex is None:
         vertex = TVector3()
     pdg_id = None
     propagate_to = None
     if layer=='ecal_in':
         pdg_id = 22 #photon
         propagate_to = [ self.detector.elements['ecal'].volume.inner ]
     elif layer=='hcal_in':
         pdg_id = 130 #K0
         propagate_to = [ self.detector.elements['ecal'].volume.inner,
                          self.detector.elements['hcal'].volume.inner ]
     else:
         raise ValueError('layer must be equal to ecal_in or hcal_in')
     assert(pdg_id)
     mass, charge = particle_data[pdg_id]
     if energy is None:
         energy = cluster.energy
     if energy < mass: 
         return None 
     if mass == 0:
         momentum = energy #avoid sqrt for zero mass
     else:
         momentum = math.sqrt(energy**2 - mass**2)
     p3 = cluster.position.Unit() * momentum
     p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(), energy) #mass is not accurate here
     particle = Particle(p4, vertex, charge, pdg_id)
     particle.set_dagid(IdCoder.make_id(IdCoder.PFOBJECTTYPE.PARTICLE, len(self.particles), 'r', particle.idvalue))
     
     # alice: this may be a bit strange because we can make a photon 
     # with a path where the point is actually that of the hcal?
     # nb this only is problem if the cluster and the assigned layer 
     # are different
     propagator(charge).propagate([particle],
                                  propagate_to)
     #merge Nov 10th 2016 not sure about following line (was commented out in papasevent branch)
     particle.clusters[layer] = cluster  # not sure about this either when hcal is used to make an ecal cluster?
     self.locked[cluster.uniqueid] = True #just OK but not nice if hcal used to make ecal.
     pdebugger.info(str('Made {} from {}'.format(particle, cluster)))
     self.insert_particle(parent_ids, particle)        
示例#12
0
 def reconstruct_track(self, track, pdgid, parent_ids,
                       clusters=None): # cluster argument does not ever seem to be used at present
     '''construct a charged hadron from the track
     '''
     if self.locked[track.uniqueid]:
         return 
     vertex = track.path.points['vertex']
     pdgid = pdgid * track.charge
     mass, charge = particle_data[pdgid]
     p4 = TLorentzVector()
     p4.SetVectM(track.p3, mass)
     particle = Particle(p4, vertex, charge, len(self.particles), pdgid,  subtype='r')
     #todo fix this so it picks up smeared track points (need to propagagte smeared track)
     particle.set_track(track) #refer to existing track rather than make a new one
     self.locked[track.uniqueid] = True
     pdebugger.info(str('Made {} from {}'.format(particle, track)))
     self.insert_particle(parent_ids, particle)
     return particle
示例#13
0
 def reconstruct_cluster(self, cluster, layer, energy=None, vertex=None):
     """construct a photon if it is an ecal
        construct a neutral hadron if it is an hcal
     """
     if vertex is None:
         vertex = TVector3()
     pdg_id = None
     propagate_to = None
     if layer == "ecal_in":
         pdg_id = 22  # photon
         propagate_to = [self.detector.elements["ecal"].volume.inner]
     elif layer == "hcal_in":
         pdg_id = 130  # K0
         propagate_to = [self.detector.elements["ecal"].volume.inner, self.detector.elements["hcal"].volume.inner]
     else:
         raise ValueError("layer must be equal to ecal_in or hcal_in")
     assert pdg_id
     mass, charge = particle_data[pdg_id]
     if energy is None:
         energy = cluster.energy
     if energy < mass:
         return None
     if mass == 0:
         momentum = energy  # avoid sqrt for zero mass
     else:
         momentum = math.sqrt(energy ** 2 - mass ** 2)
     p3 = cluster.position.Unit() * momentum
     p4 = TLorentzVector(p3.Px(), p3.Py(), p3.Pz(), energy)  # mass is not accurate here
     particle = Particle(p4, vertex, charge, pdg_id, Identifier.PFOBJECTTYPE.RECPARTICLE)
     # path = StraightLine(p4, vertex)
     # path.points[layer] = cluster.position
     # alice: this may be a bit strange because we can make a photon
     # with a path where the point is actually that of the hcal?
     # nb this only is problem if the cluster and the assigned layer
     # are different
     # particle.set_path(path)
     propagator(charge).propagate([particle], propagate_to)
     particle.clusters[layer] = cluster  # not sure about this either when hcal is used to make an ecal cluster?
     self.locked[cluster.uniqueid] = True  # just OK but not nice if hcal used to make ecal.
     pdebugger.info(str("Made {} from {}".format(particle, cluster)))
     return particle
示例#14
0
文件: PapasSim.py 项目: HEP-FCC/heppy
 def simparticle(ptc, index):
     '''Create a sim particle to be used in papas from an input particle.
     '''
     tp4 = ptc.p4()
     vertex = ptc.start_vertex().position()
     charge = ptc.q()
     pid = ptc.pdgid()
     simptc = Particle(tp4, vertex, charge, pid)
     simptc.set_dagid(IdCoder.make_id(IdCoder.PFOBJECTTYPE.PARTICLE, index, 's', simptc.idvalue))
     pdebugger.info(" ".join(("Made", simptc.__str__())))
     #simptc.gen_ptc = ptc
     #record that sim particle derives from gen particle
     child = papasevent.history.setdefault(simptc.dagid(), Node(simptc.dagid())) #creates a new node if it is not there already
     parent = papasevent.history.setdefault(ptc.dagid(), Node(ptc.dagid()))
     parent.add_child(child)
     return simptc
示例#15
0
 def simparticle(ptc, index):
     '''Create a sim particle to be used in papas from an input particle.
     '''
     tp4 = ptc.p4()
     vertex = ptc.start_vertex().position()
     charge = ptc.q()
     pid = ptc.pdgid()
     simptc = Particle(tp4, vertex, charge, pid)
     simptc.set_dagid(
         IdCoder.make_id(IdCoder.PFOBJECTTYPE.PARTICLE, index, 's',
                         simptc.idvalue))
     pdebugger.info(" ".join(("Made", simptc.__str__())))
     #simptc.gen_ptc = ptc
     #record that sim particle derives from gen particle
     child = papasevent.history.setdefault(
         simptc.dagid(), Node(simptc.dagid(
         )))  #creates a new node if it is not there already
     parent = papasevent.history.setdefault(ptc.dagid(),
                                            Node(ptc.dagid()))
     parent.add_child(child)
     return simptc