def print_crystal_placement(self, idxclover, coord=None): theta_rotation = TRotation() phi_rotation = TRotation() theta_rotation.RotateY(self.placement.Theta()) phi_rotation.RotateZ(self.placement.Phi()) for k, (xsign, ysign) in enumerate([(-1, +1), (+1, +1), (-1, -1), (+1, -1)]): crystal_offset = TVector3(xsign * self.xdispl, ysign * self.ydispl, self.covergap) crystal_offset = phi_rotation * theta_rotation * crystal_offset crystal = TVector3(self.placement.X() + crystal_offset.X(), self.placement.Y() + crystal_offset.Y(), self.placement.Z() + crystal_offset.Z()) if coord == "Spherical": print("clover.{0:02d}.{1}.{2}.vec_sph: ".format( idxclover, chr(0x40 + k + 1), 0) + str(np.around(crystal.Mag(), 10)) + " " + str(np.around(crystal.Theta() * 180 / np.pi, 10)) + " " + str(np.around(crystal.Phi() * 180 / np.pi, 10))) else: print("clover.{0:02d}.{1}.{2}.vec: ".format( idxclover, chr(0x40 + k + 1), 0) + str(np.around(crystal.X(), 10)) + " " + str(np.around(crystal.Y(), 10)) + " " + str(np.around(crystal.Z(), 10))) print("")
tankparams = [] for i in range(len(tankz)): tankparams.append(tankrmin[i]) tankparams.append(tankrmax[i]) tankparams.append(tankz[i]-cerz0) motherparams = [] motherparams.append(tankrmin[0]) motherparams.append(tankrmin[0]) motherparams.append(tankz[0]-cerz0 - cleo_bw_thk) motherparams += tankparams motherparams.append(tankrmin[-1]) motherparams.append(tankrmin[-1]) motherparams.append(tankz[-1]-cerz0 + cleo_bw_thk) mir_rotz = TRotation() mir_rotz.RotateZ(2.0*pi/nsector) #initialize it so we have zero rotation when we start pmt_rotz = TRotation() pmt_rotx = TRotation() pmt_roty = TRotation() pmt_rotz.RotateZ(pmtz_ang) pmt_roty.RotateY(pmty_ang) pmt_rotx.RotateX(pmtx_ang) Pos_obs_hfloff = TVector3(0.0, 0.0, -PMT_hflngth) Pos_obs_hfloff = pmt_roty*Pos_obs_hfloff Pos_obs_hfloff = pmt_rotx*Pos_obs_hfloff Pos_obs_V = Pos_obs_V + Pos_obs_hfloff
def upsilonMuDirections(chib_p4, Upsilon_p4, muP_p4, frame='hx'): """return two directions: 1. direction vector of Upsilon in the chib rest frame, wrt to the direction of chib 2. direction vector of muon in the Uspilon rest frame, wrt to the direction of the Upsilon as seen in the chib rest frame""" pbeam = 4000 # 4 TeV each Mups = 9.4603 Mprot = 0.938 Ebeam = sqrt(pbeam**2 + Mprot**2) targ = TLorentzVector(0., 0., -pbeam, Ebeam) beam = TLorentzVector(0., 0., pbeam, Ebeam) # chib 4vector in lab frame chi = chib_p4 chi_direction = chi.Vect().Unit() # Upsilon 4vector in lab fram ups = Upsilon_p4 cm_to_chi = -chi.BoostVector() chi_to_cm = chi.BoostVector() cm_to_ups = -ups.BoostVector() beam_chi = beam beam_chi.Boost(cm_to_chi) # beam in the chi rest frame targ_chi = targ targ_chi.Boost(cm_to_chi) # target in the chi rest frame beam_direction_chi = beam_chi.Vect().Unit() targ_direction_chi = targ_chi.Vect().Unit() beam_targ_bisec_chi = (beam_direction_chi - targ_direction_chi).Unit() ups_chi = ups ups_chi.Boost(cm_to_chi) # Upsilon in the chib rest frame ups_direction_chi = ups_chi.Vect().Unit() # all polarization frames have the same Y axis = the normal to the plane # formed by the directions of the colliding hadrons Yaxis = (beam_direction_chi.Cross(targ_direction_chi)).Unit() # transform(rotation) ups momentum components from polarization axis system # to the system with x,y,z axes as in the laboratory ChiPolAxis = chi_direction # helicity frame if frame is 'cs': ChiPolAxis = beam_targ_bisec_chi newZaxis = ChiPolAxis newYaxis = Yaxis newXaxis = newYaxis.Cross(newZaxis) # rotation needed to go to the chi rest frame rotation = TRotation() rotation.SetToIdentity() rotation.RotateAxes(newXaxis, newYaxis, newZaxis) rotation.Invert() ups_chi_rotated = ups_chi.Vect() ups_chi_rotated.Transform(rotation) # direction of the ups in the chi rest frame # relative to direction of chi in the lab # now calculate muon direction in the Upsilon rest frame wrt chi direction mumass = 0.105 Yaxis = (ChiPolAxis.Cross(ups_direction_chi)).Unit() newZaxis = ups_direction_chi newYaxis = Yaxis newXaxis = newYaxis.Cross(newZaxis) rotation.SetToIdentity() rotation.RotateAxes(newXaxis, newYaxis, newZaxis) rotation.Invert() #muon in the lab lepton = muP_p4 #muon in the ups rest frame lepton_ups = lepton lepton_ups.Boost(cm_to_ups) lepton_ups_rotated = lepton_ups.Vect() lepton_ups_rotated.Transform(rotation) return ups_chi_rotated, lepton_ups_rotated
def jpsimuDirections(chiccand, jpsicand, frame='hx'): """return two directions: 1. direction vector of jpsi in the chic rest frame, wrt to the direction of chic 2. direction vector of muon in the jpsi rest frame, wrt to the direction of the psi as seen in the chic rest frame""" pbeam = 3500 Mpsi = 3.097 Mprot = 0.938 Ebeam = sqrt(pbeam**2 + Mprot**2) targ = TLorentzVector(0., 0., -pbeam, Ebeam) beam = TLorentzVector(0., 0., pbeam, Ebeam) # chic 4vector in lab frame chi = TLorentzVector() #chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), mass) chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), chiccand.mass()) chi_direction = chi.Vect().Unit() # psi 4vector in lab fram psi = TLorentzVector() psi.SetXYZM(jpsicand.px(), jpsicand.py(), jpsicand.pz(), jpsicand.mass()) cm_to_chi = -chi.BoostVector() chi_to_cm = chi.BoostVector() cm_to_psi = -psi.BoostVector() beam_chi = beam beam_chi.Boost(cm_to_chi) # beam in the chi rest frame targ_chi = targ targ_chi.Boost(cm_to_chi) # target in the chi rest frame beam_direction_chi = beam_chi.Vect().Unit() targ_direction_chi = targ_chi.Vect().Unit() beam_targ_bisec_chi = (beam_direction_chi - targ_direction_chi).Unit() psi_chi = psi psi_chi.Boost(cm_to_chi) # psi in the chi rest frame psi_direction_chi = psi_chi.Vect().Unit() # all polarization frames have the same Y axis = the normal to the plane # formed by the directions of the colliding hadrons Yaxis = (beam_direction_chi.Cross(targ_direction_chi)).Unit() # transform(rotation) psi momentum components from polarization axis system # to the system with x,y,z axes as in the laboratory ChiPolAxis = chi_direction # helicity frame if frame is 'cs': ChiPolAxis = beam_targ_bisec_chi newZaxis = ChiPolAxis newYaxis = Yaxis newXaxis = newYaxis.Cross(newZaxis) # rotation needed to go to the chi rest frame rotation = TRotation() rotation.SetToIdentity() rotation.RotateAxes(newXaxis, newYaxis, newZaxis) rotation.Invert() psi_chi_rotated = psi_chi.Vect() psi_chi_rotated.Transform(rotation) # direction of the psi in the chi rest frame # relative to direction of chi in the lab # now calculate muon direction in the jpsi rest frame wrt chi direction mumass = 0.105 Yaxis = (ChiPolAxis.Cross(psi_direction_chi)).Unit() newZaxis = psi_direction_chi newYaxis = Yaxis newXaxis = newYaxis.Cross(newZaxis) rotation.SetToIdentity() rotation.RotateAxes(newXaxis, newYaxis, newZaxis) rotation.Invert() #muon in the lab lepton = TLorentzVector() lepton.SetXYZM( jpsicand.daughter(0).px(), jpsicand.daughter(0).py(), jpsicand.daughter(0).pz(), mumass) #muon in the psi rest frame lepton_psi = lepton lepton_psi.Boost(cm_to_psi) lepton_psi_rotated = lepton_psi.Vect() lepton_psi_rotated.Transform(rotation) return psi_chi_rotated, lepton_psi_rotated
def ZYXrotToXYZ(x, y, z): tol = 1e-8 arot = TRotation() arot.RotateZ(z) arot.RotateY(y) arot.RotateX(x) for tix in range(2): for tiy in range(2): for tiz in range(2): testy = -asin(arot.ZX()) if tiy == 0: thisy = testy else: thisy = pi - testy testx = asin(arot.ZY() / cos(thisy)) if tix == 0: thisx = testx else: thisx = pi - testx testz = asin(arot.YX() / cos(thisy)) if tiz == 0: thisz = testz else: thisz = pi - testz isequiv = True newrot = TRotation() newrot.RotateX(thisx) newrot.RotateY(thisy) newrot.RotateZ(thisz) for mi in range(3): for mj in range(3): if (fabs(newrot(mi, mj) - arot(mi, mj)) > tol): isequiv = False if isequiv: break if tix == 2 or tiy == 2 or tiz == 2: print "Error: could not find equivalent rotation matrix" exit(1) return (thisx, thisy, thisz)