Esempio n. 1
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
Esempio n. 2
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)        
Esempio n. 3
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)
     particle.set_dagid(IdCoder.make_id(IdCoder.PFOBJECTTYPE.PARTICLE, len(self.particles), 'r', particle.idvalue))
     
     #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
Esempio n. 4
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