def neut_eta(): #neutron pseudorapidity etabin = 0.05 etamin = -20 etamax = 20 hEta = ut.prepare_TH1D("hEta", etabin, etamin, etamax) can = ut.box_canvas() particles = TClonesArray("TParticle", 200) tree.SetBranchAddress("particles", particles) nev = tree.GetEntriesFast() #nev = 24 for iev in xrange(nev): tree.GetEntry(iev) for imc in xrange(particles.GetEntriesFast()): part = particles.At(imc) if part.GetPdgCode() != 2112: continue hEta.Fill(part.Eta()) ut.put_yx_tit(hEta, "Events", "#eta", 1.4, 1.2) hEta.Draw() gPad.SetGrid() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def neut_en(): #neutron energy ebin = 0.5 emin = 50 #emax = 200 emax = 1000 #ebin = 10 #emin = 500 #emax = 3000 hE = ut.prepare_TH1D("hE", ebin, emin, emax) can = ut.box_canvas() particles = TClonesArray("TParticle", 200) tree.SetBranchAddress("particles", particles) nev = tree.GetEntriesFast() #nev = 24 for iev in xrange(nev): tree.GetEntry(iev) esum = 0. for imc in xrange(particles.GetEntriesFast()): part = particles.At(imc) if part.GetPdgCode() != 2112: continue esum += part.Energy() hE.Fill(esum) ut.put_yx_tit(hE, "Events", "E (GeV)", 1.4, 1.2) hE.Draw() gPad.SetGrid() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def neut_abs_eta(): #neutron absolute pseudorapidity etabin = 0.05 etamin = 5 etamax = 20 hEta = ut.prepare_TH1D("hEta", etabin, etamin, etamax) can = ut.box_canvas() particles = TClonesArray("TParticle", 200) tree.SetBranchAddress("particles", particles) nev = tree.GetEntriesFast() #nev = 24 for iev in xrange(nev): tree.GetEntry(iev) for imc in xrange(particles.GetEntriesFast()): part = particles.At(imc) if part.GetPdgCode() != 2112: continue #hEta.Fill( TMath.Abs(part.Eta()) ) hEta.Fill(abs(part.Eta())) ytit = "Events / {0:.2f}".format(etabin) ut.put_yx_tit(hEta, ytit, "Neutron |#kern[0.3]{#eta}|", 1.4, 1.2) ut.set_H1D_col(hEta, rt.kRed) ut.set_margin_lbtr(gPad, 0.1, 0.09, 0.01, 0.02) hEta.Draw() gPad.SetGrid() gPad.SetLogy() ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")
def read_particles(): #particles clones array #tree.Print() particles = TClonesArray("TParticle", 200) tree.SetBranchAddress("particles", particles) #nev = tree.GetEntriesFast() nev = 12 for iev in xrange(nev): tree.GetEntry(iev) print iev nmc = particles.GetEntriesFast() for imc in xrange(nmc): part = particles.At(imc) print " ", imc, part.GetPdgCode(), part.Px(), part.Py(), part.Pz( ), part.Energy()
class STnOOnRead: #_____________________________________________________________________________ def __init__(self, infile): #energy in event at positive and negative rapidity self.epos = 0. self.eneg = 0. #number of neutrons at positive and negative rapidity self.npos = 0 self.nneg = 0 #flag for XnXn event self.is_XnXn = False #flag for central event self.is_Cen = False #J/psi kinematics self.pT = 0. self.y = 0. self.m = 0. #absolute eta for electron and positron self.aeta_max = 1. #minimal electron and positron for central trigger #self.p_min = 1.014 #open the input self.inp = TFile.Open(infile) self.tree = self.inp.Get("slight_tree") #connect the input tree self.particles = TClonesArray("TParticle", 200) self.tree.SetBranchAddress("particles", self.particles) #number of events in input tree self.nev = self.tree.GetEntriesFast() #__init__ #_____________________________________________________________________________ def read(self, iev): #read a given event if iev >= self.nev: return False self.tree.GetEntry(iev) #initialize event variables self.epos = 0. self.eneg = 0. self.npos = 0 self.nneg = 0 self.is_XnXn = False self.is_Cen = True vec = TLorentzVector() #particle loop for imc in xrange(self.particles.GetEntriesFast()): part = self.particles.At(imc) #central electron and positron if TMath.Abs(part.GetPdgCode()) == 11: if TMath.Abs(part.Eta()) > self.aeta_max: self.is_Cen = False #if part.P() < self.p_min: self.is_Cen = False pv = TLorentzVector() part.Momentum(pv) vec += pv #select the neutrons if part.GetPdgCode() != 2112: continue #energy at positive and negative rapidity if part.Eta() > 0: self.epos += part.Energy() self.npos += 1 else: self.eneg += part.Energy() self.nneg += 1 #particle loop #flag for XnXn event if self.npos > 0 and self.nneg > 0: self.is_XnXn = True #J/psi kinematics self.pT = vec.Pt() self.y = vec.Rapidity() self.m = vec.M() return True
def neut_en_pn(): #neutron energy and positive and negative rapidity #plot range ebin = 3 #emin = 1 emin = 30 #emax = 1400 emax = 710 #analysis cuts eta_max = 6.6 # absolute eta en_max = 1250 # energy en_min = 20 hE = ut.prepare_TH2D("hE", ebin, emin, emax, ebin, emin, emax) can = ut.box_canvas() particles = TClonesArray("TParticle", 200) tree.SetBranchAddress("particles", particles) nev = tree.GetEntriesFast() #nev = int(1e4) nall = 0. nsel = 0. for iev in xrange(nev): tree.GetEntry(iev) epos = 0. eneg = 0. for imc in xrange(particles.GetEntriesFast()): part = particles.At(imc) if part.GetPdgCode() != 2112: continue #ZDC eta if abs(part.Eta()) < eta_max: continue if part.Eta() > 0: epos += part.Energy() else: eneg += part.Energy() if epos < en_min or eneg < en_min: continue nall += 1. if epos > en_max or eneg > en_max: continue #if epos < en_min or epos > en_max: continue #if eneg < en_min or eneg > en_max: continue nsel += 1. hE.Fill(eneg, epos) print nall, nsel, nsel / nall ut.put_yx_tit(hE, "#it{E}_{#it{n}} (GeV), #it{#eta} > 0", "#it{E}_{#it{n}} (GeV), #it{#eta} < 0", 1.7, 1.2) ut.set_margin_lbtr(gPad, 0.12, 0.09, 0.02, 0.11) hE.SetMinimum(0.98) hE.SetContour(300) hE.Draw() gPad.SetGrid() gPad.SetLogz() #ut.invert_col(rt.gPad) can.SaveAs("01fig.pdf")