Exemplo n.º 1
0
    def __init__(self):

        #interaction cross section, mb
        self.sigma_tot = 0.

        #instantaneous luminosity, cm^-2 sec^-1
        self.lumi_cmsec = 0.

        #number of bunches
        self.nbunch = 0.

        #electron beam energy, GeV
        self.Ee = 0.

        #coincidence selection
        self.emin = 1.  # GeV

        #collider circumference, speed of light, electron mass
        self.circ = 3834.  # m
        self.cspeed = 299792458.  # m sec^-1
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()  # GeV

        #input
        self.tree = TChain("DetectorTree")

        #geometry
        self.geo = None

        #output file name
        self.outfile = "hits_spect.root"
Exemplo n.º 2
0
    def __init__(self,
                 funcName,
                 minMass,
                 maxMass,
                 numSigmaSideBands=0.,
                 peakMass=0.,
                 peakSigma=0.,
                 secPeakMass=0.,
                 secPeakSigma=0.):
        if funcName not in self.__implFunc:
            raise ValueError(f'Function \'{funcName}\' not implemented')
        self.funcName = funcName
        self.minMass = minMass
        self.maxMass = maxMass
        self.peakMass = peakMass
        self.peakDelta = peakSigma * numSigmaSideBands
        self.secPeakMass = secPeakMass
        self.secPeakDelta = secPeakSigma * numSigmaSideBands
        self.funcSBCallable = None
        self.funcFullCallable = None

        self.removePeak = False
        self.removeSecPeak = False
        if self.peakMass > 0. and self.peakDelta > 0.:
            self.removePeak = True
        if self.secPeakMass > 0. and self.secPeakDelta > 0.:
            self.removeSecPeak = True

        self.mPi = TDatabasePDG.Instance().GetParticle(211).Mass()
Exemplo n.º 3
0
    def __init__(self, parse, tree, hepmc_attrib):

        #minumum and maximum energy, GeV
        self.emin = parse.getfloat("main", "emin")
        self.emax = parse.getfloat("main", "emax")
        print("emin =", self.emin)
        print("emax =", self.emax)

        #pdg for generated particle, electron or photon
        self.pdg = 22
        if parse.has_option("main", "pdg"):
            self.pdg = parse.getint("main", "pdg")

        print("pdg =", self.pdg)

        #angular range, electrons for now
        self.theta_min = 0.
        self.theta_max = 0.

        #angles as mlt = -log_10(pi - theta)
        if parse.has_option("main", "mlt_min"):
            mlt_min = parse.getfloat("main", "mlt_min")
            mlt_max = parse.getfloat("main", "mlt_max")
            print("mlt_min =", mlt_min)
            print("mlt_max =", mlt_max)
            self.theta_min = TMath.Pi() - 10.**(-mlt_min)
            self.theta_max = TMath.Pi() - 10.**(-mlt_max)

        print("theta_min =", self.theta_min)
        print("theta_max =", self.theta_max)

        #generator functions for photons and electrons
        self.gen_func = {}
        self.gen_func[22] = self.gen_phot
        self.gen_func[11] = self.gen_el

        #test for pdg
        if self.gen_func.get(self.pdg) is None:
            print("Fatal: pdg", self.pdg, "is not supported")
            raise KeyError

        #uniform generator
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #electron mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()

        #set the output tree
        if self.pdg == 22:
            tnam = ["gen_E"]
        if self.pdg == 11:
            tnam = ["true_el_pT", "true_el_theta", "true_el_phi", "true_el_E"]
        self.out = self.make_tree(tree, tnam)

        #event attributes for hepmc
        self.hepmc_attrib = hepmc_attrib

        print("Uniform generator initialized")
Exemplo n.º 4
0
    def __init__(self, parse):

        #energy of electron beam, GeV
        self.Ee = parse.getfloat("main", "Ee")
        #proton beam, GeV
        self.Ep = parse.getfloat("main", "Ep")

        print("Ee =", self.Ee, "GeV")
        print("Ep =", self.Ep, "GeV")

        #minimal photon energy, GeV
        self.emin = parse.getfloat("main", "emin")
        print("emin =", self.emin)

        #electron and proton mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        self.mp = TDatabasePDG.Instance().GetParticle(2212).Mass()
        self.mep = self.me * self.mp

        #CMS energy squared, GeV^2
        self.s = 2 * self.Ee * self.Ep + self.me**2 + self.mp**2
        self.s += 2 * TMath.Sqrt(self.Ee**2 -
                                 self.me**2) * TMath.Sqrt(self.Ep**2 -
                                                          self.mp**2)
        print("s =", self.s, "GeV^2")

        #normalization,  4 alpha r_e^2
        self.ar2 = 4 * 7.297 * 2.818 * 2.818 * 1e-2  # m barn

        #parametrizations for dSigma/dy and dSigma/dtheta
        gRandom.SetSeed(5572323)
        self.eq1par = self.eq1(self)
        self.dSigDy = TF1("dSigDy", self.eq1par, self.emin / self.Ee, 1)
        tmax = 1.5e-3  #maximal photon angle
        self.eq3par = self.eq3(self)
        self.dSigDtheta = TF1("dSigDtheta", self.eq3par, 0, tmax)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        print("H1 parametrization initialized")
        print("Total cross section: " +
              str(self.dSigDy.Integral(self.emin / self.Ee, 1)) + " mb")
Exemplo n.º 5
0
def get_scale(Ni):

    #scale for event rate in Hz per one simulated interaction
    #Ni is number of simulated interactions

    #interaction cross section, mb
    sigma_tot = 171.29  # 18x275
    #sigma_tot = 123.83 # 10x100
    #sigma_tot = 79.18 # 5x41

    #instantaneous luminosity, cm^-2 sec^-1
    lumi_cmsec = 1.54e33  # 18x275
    #lumi_cmsec = 4.48e33 # 10x100
    #lumi_cmsec = 0.44e33 # 5x41

    #number of bunches
    nbunch = 290  # 18x275
    #nbunch = 1160 # 10x100
    #nbunch = 1160 # 5x41

    #electron beam energy, GeV
    #Ee = 18. # GeV
    #Ee = 10. # GeV
    Ee = 5.  # GeV

    #collider circumference, speed of light, electron mass
    circ = 3834.  # m
    cspeed = 299792458.  # m sec^-1
    me = TDatabasePDG.Instance().GetParticle(11).Mass()  # GeV

    #beam velocity (units of c)
    beta = np.sqrt(Ee**2 - me**2) / Ee
    print("Beta:", beta)
    print("Orbit period (micro sec):", 1e6 * circ / (beta * cspeed))

    #bunch spacing, sec
    Tb = circ / (beta * cspeed * nbunch)
    print("Bunch spacing (micro sec):", 1e6 * Tb)
    print("Bunch frequency (MHz):", 1e-6 / Tb)

    #luminosity per bunch crossing, mb^-1
    Lb = lumi_cmsec * 1e-27 * Tb
    print("Luminosity per bunch crossing, mb^-1:", Lb)
    print("Mean number of interactions per bunch crossing:", sigma_tot * Lb)
    print("Probability for at least one interaction in bunch crossing:",
          (1. - np.e**(-sigma_tot * Lb)))

    scale = {}
    scale["lambda"] = sigma_tot * Lb
    scale["Tb"] = Tb  # sec

    #rate per one simulated interaction, Hz
    #return (1./Ni)*sigma_tot*1e-27*lumi_cmsec

    return scale
Exemplo n.º 6
0
    def __init__(self, parse):

        #electron beam, GeV
        self.Ee = parse.getfloat("main", "Ee")
        #proton beam, GeV
        self.Ep = parse.getfloat("main", "Ep")

        print("Ee =", self.Ee, "GeV")
        print("Ep =", self.Ep, "GeV")

        #minimal photon energy, GeV
        self.emin = parse.getfloat("main", "emin")
        print("emin =", self.emin)

        #maximal photon angle
        self.tmax = 1.5e-3
        if parse.has_option("main", "tmax"):
            self.tmax = parse.getfloat("main", "tmax")

        #electron and proton mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        self.mp = TDatabasePDG.Instance().GetParticle(2212).Mass()
        self.mep = self.me * self.mp

        #normalization,  4 alpha r_e^2
        self.ar2 = 4*7.297*2.818*2.818*1e-2 # m barn

        #parametrizations for dSigma/dE_gamma and dSigma/dtheta
        gRandom.SetSeed(5572323)
        self.eq1par = self.eq1(self)
        self.dSigDe = TF1("dSigDe", self.eq1par, self.emin, self.Ee)

        self.theta_const = 1e-11 # constant term in theta formula
        self.eq2par = self.eq2(self)
        self.dSigDtheta = TF1("dSigDtheta", self.eq2par, 0, self.tmax)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        print("ZEUS parametrization initialized")
        print("Total cross section: "+str(self.dSigDe.Integral(self.emin, self.Ee))+" mb")
Exemplo n.º 7
0
    def __init__(self, en, pdg, zsign):
        #energy, pdg, sign of z-momentum

        particle.__init__(self, pdg)
        self.pdg = pdg
        #status code for beam particles
        self.stat = 201
        #set kinematics for beam particle
        m = TDatabasePDG.Instance().GetParticle(pdg).Mass()
        pz = zsign * sqrt(en**2 - m**2)
        self.vec.SetPxPyPzE(0, 0, pz, en)
Exemplo n.º 8
0
    def get_s(self, Ee, Ep):

        #calculate the CMS squared s

        #proton mass
        mp = TDatabasePDG.Instance().GetParticle(2212).Mass()

        #CMS energy squared s, GeV^2
        s = 2.*Ee*Ep + self.me**2 + mp**2
        s += 2*TMath.Sqrt(Ee**2 - self.me**2) * TMath.Sqrt(Ep**2 - mp**2)

        #print "sqrt(s):", TMath.Sqrt(s)

        return s
Exemplo n.º 9
0
def q2_calc_vec_from_kine(en, theta, phi):

    #create Lorentz vector from electron kinematics loaded from the tree

    #transverse momentum
    m = TDatabasePDG.Instance().GetParticle(11).Mass()
    pt = sqrt(0.5 * (en**2 - m**2) * (1. - cos(2. * theta)))

    #pseudorapidity
    eta = -log(tan(theta / 2.))

    #set the Lorentz vector
    vec = TLorentzVector()
    vec.SetPtEtaPhiE(pt, eta, phi, en)

    return vec
Exemplo n.º 10
0
    def __init__(self, en, theta, phi):
        particle.__init__(self, 11)

        #transverse momentum
        m = TDatabasePDG.Instance().GetParticle(11).Mass()
        pt = sqrt(0.5 * (en**2 - m**2) * (1. - cos(2. * theta)))

        #pseudorapidity, rotate the theta for pz negative
        theta = pi - theta
        eta = -log(tan(theta / 2.))

        #set the electron Lorentz vector
        self.vec.SetPtEtaPhiE(pt, eta, phi, en)

        #status for the final particle
        self.stat = 1
Exemplo n.º 11
0
    def __init__(self, parse):

        #electron beam energy, GeV
        self.Ee = parse.getfloat("main", "Ee")
        print("Ee =", self.Ee)

        #energy spread from input relative energy spread
        self.espread = None
        if parse.has_option("main", "espread"):
            sig_e = self.Ee * parse.getfloat("main", "espread")
            self.espread = TF1("espread", "gaus", -12 * sig_e, 12 * sig_e)
            self.espread.SetParameters(1, 0, sig_e)

        #electron mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()

        print("Electron beam initialized")
Exemplo n.º 12
0
 def __init__(self, pdg):
     #particle Lorentz vector
     self.vec = TLorentzVector()
     #index in particle list
     self.idx = 0
     #status code
     self.stat = 0
     #pdg code
     self.pdg = pdg
     #particle database for pass and codes
     self.pdgdat = TDatabasePDG.Instance()
     #mass, GeV
     self.mass = self.pdgdat.GetParticle(self.pdg).Mass()
     #parent particle id
     self.parent_id = 0
     #vertex coordinates, mm
     self.vx = 0.
     self.vy = 0.
     self.vz = 0.
     #precision for momentum and energy
     self.pxyze_prec = 6
Exemplo n.º 13
0
                   markerstyle=markersData[cut])
hEffPtIntMC = TH1F('hEffPtIntMC', ';|#Delta#it{M}(KK)| selection; efficiency',
                   21, 4.5, 25.5)
hEffPtIntData = TH1F('hEffPtIntData',
                     ';|#Delta#it{M}(KK)| selection; efficiency', 21, 4.5,
                     25.5)
SetObjectStyle(hEffPtIntMC,
               color=kRed + 1,
               fillstyle=0,
               markerstyle=kFullSquare)
SetObjectStyle(hEffPtIntData,
               color=kAzure + 4,
               fillstyle=0,
               markerstyle=kFullCircle)

massPhi = TDatabasePDG.Instance().GetParticle(333).Mass()
massK = TDatabasePDG.Instance().GetParticle(321).Mass()
widthPhi = TDatabasePDG.Instance().GetParticle(333).Width()

for iPt in range(nPtBinsMC):
    if iPt < nPtBinsMC - 1:
        ptMin = ptLims[iPt]
        ptMax = ptLims[iPt + 1]
    else:
        ptMin = ptLims[0]
        ptMax = ptLims[-1]

    # get massKK distributions in signal region
    massLowLimit = mean[iPt] - args.nSigma * sigma[iPt]
    massHighLimit = mean[iPt] + args.nSigma * sigma[iPt]
    binLow = hMassKKvsMassKKpiMC[iPt].GetXaxis().FindBin(massLowLimit * 1.0001)
Exemplo n.º 14
0
def main():

    #input
    inp = TFile.Open("pC.root")
    tree = inp.Get("DetectorTree")

    #input generated particles
    gen_pdg = std.vector(int)()
    gen_en = std.vector(float)()
    tree.SetBranchAddress("gen_pdg", gen_pdg)
    tree.SetBranchAddress("gen_en", gen_en)

    #layer hits
    lay10_hit_edep = std.vector(float)()
    lay11_hit_edep = std.vector(float)()
    lay12_hit_edep = std.vector(float)()
    lay13_hit_edep = std.vector(float)()
    lay20_hit_edep = std.vector(float)()
    lay21_hit_edep = std.vector(float)()
    lay22_hit_edep = std.vector(float)()
    lay23_hit_edep = std.vector(float)()
    tree.SetBranchAddress("lay10_HitEdep", lay10_hit_edep)
    tree.SetBranchAddress("lay11_HitEdep", lay11_hit_edep)
    tree.SetBranchAddress("lay12_HitEdep", lay12_hit_edep)
    tree.SetBranchAddress("lay13_HitEdep", lay13_hit_edep)
    tree.SetBranchAddress("lay20_HitEdep", lay20_hit_edep)
    tree.SetBranchAddress("lay21_HitEdep", lay21_hit_edep)
    tree.SetBranchAddress("lay22_HitEdep", lay22_hit_edep)
    tree.SetBranchAddress("lay23_HitEdep", lay23_hit_edep)

    #output
    out = TFile("events.root", "recreate")
    otree = TTree("event", "event")
    ekin = c_float(0)
    lay10_edep = c_float(0)
    lay11_edep = c_float(0)
    lay12_edep = c_float(0)
    lay13_edep = c_float(0)
    lay20_edep = c_float(0)
    lay21_edep = c_float(0)
    lay22_edep = c_float(0)
    lay23_edep = c_float(0)
    otree.Branch("ekin", ekin, "ekin/F") # kinetic energy, MeV
    otree.Branch("lay10_edep", lay10_edep, "lay10_edep/F") # deposited energy, MeV
    otree.Branch("lay11_edep", lay11_edep, "lay11_edep/F")
    otree.Branch("lay12_edep", lay12_edep, "lay12_edep/F")
    otree.Branch("lay13_edep", lay13_edep, "lay13_edep/F")
    otree.Branch("lay20_edep", lay20_edep, "lay20_edep/F")
    otree.Branch("lay21_edep", lay21_edep, "lay21_edep/F")
    otree.Branch("lay22_edep", lay22_edep, "lay22_edep/F")
    otree.Branch("lay21_edep", lay23_edep, "lay23_edep/F")

    #number of events
    nev = tree.GetEntries()
    #nev = 100000

    #event loop
    for iev in range(nev):
        tree.GetEntry(iev)

        if iev%100000 == 0:
            print("Event: ", iev)

        #deposited energy, MeV
        lay10_edep.value = 0.
        lay11_edep.value = 0.
        lay12_edep.value = 0.
        lay13_edep.value = 0.
        lay20_edep.value = 0.
        lay21_edep.value = 0.
        lay22_edep.value = 0.
        lay23_edep.value = 0.

        #hit loops for layers
        nhit = 0
        nhit += get_edep_lay(lay10_hit_edep, lay10_edep)
        nhit += get_edep_lay(lay11_hit_edep, lay11_edep)
        nhit += get_edep_lay(lay12_hit_edep, lay12_edep)
        nhit += get_edep_lay(lay13_hit_edep, lay13_edep)
        nhit += get_edep_lay(lay20_hit_edep, lay20_edep)
        nhit += get_edep_lay(lay21_hit_edep, lay21_edep)
        nhit += get_edep_lay(lay22_hit_edep, lay22_edep)
        nhit += get_edep_lay(lay23_hit_edep, lay23_edep)

        #events with hits
        if nhit <= 0:
            continue

        #generated kinetic energy, MeV
        egen = gen_en.at(0)
        mass = TDatabasePDG.Instance().GetParticle(gen_pdg.at(0)).Mass()
        ekin.value = (egen-mass)*1e3 # MeV 

        #fill the output tree
        otree.Fill()

    #finish
    otree.Write()
    out.Close()
Exemplo n.º 15
0
    def __init__(self, parse, tree=None):
        self.parse = parse

        #electron energy, GeV
        self.Ee = parse.getfloat("main", "Ee")

        print("Ee, GeV =", self.Ee)

        #Z of the nucleus
        self.Z = 1
        if parse.has_option("main", "Z"):
            self.Z = parse.getint("main", "Z")
        print("Z:", self.Z)

        #minimal photon energy, GeV
        self.emin = parse.getfloat("main", "emin")
        print("emin, GeV =", self.emin)

        #alpha r_e^2
        self.ar2 = 7.297 * 2.818 * 2.818 * 1e-2  # m barn

        #electron mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()

        #maximal delta
        self.dmax = 200.
        if parse.has_option("main", "dmax"):
            self.dmax = parse.getfloat("main", "dmax")

        print("dmax:", self.dmax)

        #cross section formula
        #self.eqpar = self.eq_93p16(self)
        #self.dSigDwDt = TF2("dSigDwDt", self.eqpar, self.emin, self.Ee, 0, self.dmax)
        #self.dSigDwDt.SetNpx(2000)
        #self.dSigDwDt.SetNpy(2000)
        #self.dSigDwDt.SetNpx(100)
        #self.dSigDwDt.SetNpy(100)
        #gRandom.SetSeed(5572323)

        #total integrated cross section over all delta (to 1e5)
        #dSigInt = TF2("dSigInt", self.eqpar, self.emin, self.Ee, 0, 1e5)
        #sigma_tot = dSigInt.Integral(self.emin, self.Ee, 0, 1e5)
        #print("Total cross section, mb:", sigma_tot)

        #FOAM integration
        self.eq_foam = self.eq_93p16_foam(self)
        self.rand_foam = TRandom3()
        self.rand_foam.SetSeed(123)
        self.foam = TFoam("foam")
        self.foam.SetkDim(2)
        self.foam.SetnCells(2000)
        self.foam.SetRhoInt(self.eq_foam)
        self.foam.SetPseRan(self.rand_foam)
        self.foam.Initialize()

        #to print the total cross section from FOAM at the end
        atexit.register(self.finish)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #chamber pressure for z-vertex
        self.pressure_par = self.eq_pressure(self)
        zmin = self.pressure_par.zmin
        zmax = self.pressure_par.zmax
        #custom range in z, only within the default limits given by pressure data
        if parse.has_option(
                "main", "zmin") and (parse.getfloat("main", "zmin") > zmin):
            zmin = parse.getfloat("main", "zmin")
        if parse.has_option(
                "main", "zmax") and (parse.getfloat("main", "zmax") < zmax):
            zmax = parse.getfloat("main", "zmax")
        print("zmin, zmax (mm):", zmin, zmax)
        self.pressure_func = TF1("pressure", self.pressure_par, zmin, zmax)

        #electron lattice
        self.lat = self.load_lattice()

        #beam transverte shape for vertex in x and y
        self.beam_par = self.eq_beam_sigma(self.lat, self.pressure_par.hz,
                                           parse)

        #tree output from the generator
        tlist = ["true_phot_w", "true_phot_delta"]
        tlist += ["true_phot_theta", "true_phot_phi", "true_phot_E"]
        tlist += ["vtx_x", "vtx_y", "vtx_z", "divx", "divy"]
        self.tree_out = self.set_tree(tree, tlist)

        print("Beam-gas generator initialized")
Exemplo n.º 16
0
    def __init__(self, parse, tree, hepmc_attrib):

        print("Quasi-real configuration:")

        #electron and proton beam energy, GeV
        self.Ee = parse.getfloat("main", "Ee")
        self.Ep = parse.getfloat("main", "Ep")
        print("Ee =", self.Ee, "GeV")
        print("Ep =", self.Ep, "GeV")

        #electron and proton mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        mp = TDatabasePDG.Instance().GetParticle(2212).Mass()

        #boost vector pbvec of proton beam
        pbeam = TLorentzVector()
        pbeam.SetPxPyPzE(0, 0, TMath.Sqrt(self.Ep**2-mp**2), self.Ep)
        self.pbvec = pbeam.BoostVector()

        #electron beam energy Ee_p in proton beam rest frame
        ebeam = TLorentzVector()
        ebeam.SetPxPyPzE(0, 0, -TMath.Sqrt(self.Ee**2-self.me**2), self.Ee)
        ebeam.Boost(-self.pbvec.x(), -self.pbvec.y(), -self.pbvec.z()) # transform to proton beam frame
        self.Ee_p = ebeam.E()

        #center-of-mass squared s, GeV^2
        self.s = self.get_s(self.Ee, self.Ep)
        print("s =", self.s, "GeV^2")
        print("sqrt(s) =", TMath.Sqrt(self.s), "GeV")

        #range in x
        xmin = parse.getfloat("main", "xmin")
        xmax = parse.getfloat("main", "xmax")
        print("xmin =", xmin)
        print("xmax =", xmax)

        #range in u = log_10(x)
        umin = TMath.Log10(xmin)
        umax = TMath.Log10(xmax)
        print("umin =", umin)
        print("umax =", umax)

        #range in y
        ymin = parse.getfloat("main", "ymin")
        ymax = parse.getfloat("main", "ymax")

        #range in W
        wmin = -1.
        wmax = -1.
        if parse.has_option("main", "Wmin"):
            wmin = parse.getfloat("main", "Wmin")
            print("Wmin =", wmin)
        if parse.has_option("main", "Wmax"):
            wmax = parse.getfloat("main", "Wmax")
            print("Wmax =", wmax)

        #adjust range in y according to W
        if wmin > 0 and ymin < wmin**2/self.s:
            ymin = wmin**2/self.s
        if wmax > 0 and ymax > wmax**2/self.s:
            ymax = wmax**2/self.s

        print("ymin =", ymin)
        print("ymax =", ymax)

        #range in v = log_10(y)
        vmin = TMath.Log10(ymin)
        vmax = TMath.Log10(ymax)
        print("vmin =", vmin)
        print("vmax =", vmax)

        #range in Q2
        self.Q2min = parse.getfloat("main", "Q2min")
        self.Q2max = parse.getfloat("main", "Q2max")
        print("Q2min =", self.Q2min)
        print("Q2max =", self.Q2max)

        #constant term in the cross section
        self.const = TMath.Log(10)*TMath.Log(10)*(1./137)/(2.*math.pi)

        #cross section formula for d^2 sigma / dxdy, Eq. II.6
        #transformed as x -> u = log_10(x) and y -> v = log_10(y)
        self.eq_II6_uv_par = self.eq_II6_uv(self)
        self.eq = TF2("d2SigDuDvII6", self.eq_II6_uv_par, umin, umax, vmin, vmax)

        self.eq.SetNpx(1000)
        self.eq.SetNpy(1000)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #generator event variables in output tree
        tnam = ["gen_u", "gen_v", "true_x", "true_y", "true_Q2", "true_W2"]
        tnam += ["true_el_Q2"]
        tnam += ["true_el_pT", "true_el_theta", "true_el_phi", "true_el_E"]

        #create the tree variables
        tcmd = "struct gen_out { Double_t "
        for i in tnam:
            tcmd += i + ", "
        tcmd = tcmd[:-2] + ";};"
        gROOT.ProcessLine( tcmd )
        self.out = rt.gen_out()

        #put zero to all variables
        for i in tnam:
            exec("self.out."+i+"=0")

        #set the variables in the tree
        if tree is not None:
            for i in tnam:
                tree.Branch(i, addressof(self.out, i), i+"/D")

        #event attributes for hepmc
        self.hepmc_attrib = hepmc_attrib

        #counters for all generated and selected events
        self.nall = 0
        self.nsel = 0

        #print generator statistics at the end
        atexit.register(self.show_stat)

        #total integrated cross section
        self.sigma_tot = self.eq.Integral(umin, umax, vmin, vmax)
        print("Total integrated cross section for a given x and y range:", self.sigma_tot, "mb")

        print("Quasi-real photoproduction initialized")
Exemplo n.º 17
0
    def __init__(self, parse, tree):

        #electron and proton beam energy, GeV
        self.Ee = parse.getfloat("lgen", "Ee")
        self.Ep = parse.getfloat("lgen", "Ep")
        print "Ee =", self.Ee
        print "Ep =", self.Ep

        #electron mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()

        #center-of-mass squared s, GeV^2
        self.s = self.get_s(self.Ee, self.Ep)

        #range in x and y, max 4 orders of magnitude for the range of x
        xmin = parse.getfloat("lgen", "xmin")
        xmax = parse.getfloat("lgen", "xmax")
        print "xmin =", xmin
        print "xmax =", xmax

        #range in y
        ymin = parse.getfloat("lgen", "ymin")
        ymax = parse.getfloat("lgen", "ymax")
        print "ymin =", ymin
        print "ymax =", ymax

        #constant term in the cross section
        self.const = (1. / 137) / (2. * math.pi)

        #cross section formula for d^2 sigma / dxdy, Eq. II.6
        self.eq = TF2("d2SigDxDyII6", self.eq_II6, xmin, xmax, ymin, ymax)

        #number of points for function evaluation to generate
        #the values of x and y down to x = 1e-7
        self.eq.SetNpx(10000)  # max for npx allowed in ROOT

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #generator event variables in output tree
        tnam = ["gen_x", "gen_y", "gen_Q2", "gen_theta", "gen_E", "gen_phi"]

        #create the tree variables
        tcmd = "struct gen_out { Double_t "
        for i in tnam:
            tcmd += i + ", "
        tcmd = tcmd[:-2] + ";};"
        gROOT.ProcessLine(tcmd)

        #set the variables in the tree
        if tree is not None:
            self.out = rt.gen_out()
            for i in tnam:
                tree.Branch(i, AddressOf(self.out, i), i + "/D")

        #total integrated cross section
        self.sigma_tot = self.eq.Integral(xmin, xmax, ymin, ymax)
        print "Total integrated cross section for a given x and y range:", self.sigma_tot, "mb"

        print "Quasi-real photoproduction initialized"
def comp_fit_pars(do_ratio=False, meson='Ds'): #pylint: disable-msg=too-many-statements,too-many-locals
    inputdir = '../../AnalysisNonPromptDpp2017/Dplus/outputs/rawyields'
    input_files = ['RawYieldsDplus_pp5TeV_prompt_central.root', 'RawYieldsDplus_pp5TeV_FD_central_freesigma.root']
    input_files_MC = ['RawYieldsDplusMC_pp5TeV_prompt_central.root', 'RawYieldsDplusMC_pp5TeV_FD_central.root']
    colors = [kOrange+7, kAzure+2, kRed+1, kAzure+4]
    markers = [kOpenCircle, kOpenSquare, kFullCircle, kFullSquare]
    legendnames = ['MC - prompt enhanced', 'MC - FD enhanced', 'data - prompt enhanced', 'data - FD enhanced']
    suffix = 'CompMCData'
    min_pt = 2.
    max_pt = 16.

    SetGlobalStyle(padleftmargin=0.18, padtopmargin=0.05, padbottommargin=0.14,
                   titleoffsety=1.6, titlesize=0.045, labelsize=0.04)
    hMean, hSigma = [], []
    input_files = input_files_MC + input_files

    if meson == 'Ds':
        massD = TDatabasePDG.Instance().GetParticle(431).Mass()
    elif meson == 'Dplus':
        massD = TDatabasePDG.Instance().GetParticle(411).Mass()

    lineMass = TLine(min_pt, massD, max_pt, massD)
    lineMass.SetLineWidth(2)
    lineMass.SetLineColor(kBlack)
    lineMass.SetLineStyle(9)

    legSigma = TLegend(0.2, 0.78, 0.8, 0.93)
    legSigma.SetFillStyle(0)
    legSigma.SetBorderSize(0)
    legSigma.SetTextSize(0.04)

    legMean = TLegend(0.4, 0.73, 0.7, 0.93)
    legMean.SetFillStyle(0)
    legMean.SetBorderSize(0)
    legMean.SetTextSize(0.04)
    legMean.AddEntry(lineMass, "PDG", 'l')

    for file_path, color, marker, legend_name in zip(input_files, colors, markers, legendnames):
        input_file = TFile(f'{inputdir}/{file_path}')
        histo_mean = input_file.Get('hRawYieldsMean')
        histo_sigma = input_file.Get('hRawYieldsSigma')
        histo_mean.SetDirectory(0)
        histo_sigma.SetDirectory(0)
        SetObjectStyle(histo_mean, linecolor=color, markercolor=color, markerstyle=marker)
        SetObjectStyle(histo_sigma, linecolor=color, markercolor=color, markerstyle=marker)
        legMean.AddEntry(histo_mean, legend_name, 'p')
        legSigma.AddEntry(histo_sigma, legend_name, 'p')
        hMean.append(histo_mean)
        hSigma.append(histo_sigma)

    if do_ratio:
        mean_num_list = list(hMean)
        mean_num_list.pop(0)
        mean_den_hist = hMean[0]
        mean_ratio_list = []
        for histo in mean_num_list:
            mean_ratio_list.append(ComputeRatioDiffBins(histo, mean_den_hist))
        cMeanRatio = TCanvas('cMeanRatio', '', 800, 800)
        cMeanRatio.DrawFrame(min_pt, 0.99, max_pt, 1.01, ';#it{p}_{T} (GeV/#it{c}); peak mean / peak mean MC')
        lineRatio = TLine(min_pt, 1., max_pt, 1.)
        lineRatio.SetLineWidth(2)
        lineRatio.SetLineColor(kBlack)
        lineRatio.SetLineStyle(9)
        legMeanRatio = TLegend(0.4, 0.73, 0.7, 0.93)
        legMeanRatio.SetFillStyle(0)
        legMeanRatio.SetBorderSize(0)
        legMeanRatio.SetTextSize(0.04)
        for hist, color, marker, legend_name in zip(mean_ratio_list, colors[1:],
                                                    markers[1:], legendnames[1:]):
            SetObjectStyle(hist, linecolor=color, markercolor=color, markerstyle=marker)
            hist.Draw('same')
            legMeanRatio.AddEntry(hist, legend_name, 'p')
        lineRatio.Draw()
        legMeanRatio.Draw()

        sigma_num_list = list(hSigma)
        sigma_num_list.pop(0)
        sigma_den_hist = hSigma[0]
        sigma_ratio_list = []
        for histo in sigma_num_list:
            sigma_ratio_list.append(ComputeRatioDiffBins(histo, sigma_den_hist))
        cSigmaRatio = TCanvas('cSigmaRatio', '', 800, 800)
        hFrameSigma = cSigmaRatio.DrawFrame(min_pt, 0.6, max_pt, 1.8,
                                            ';#it{p}_{T} (GeV/#it{c}); peak width / peak width MC')
        hFrameSigma.GetYaxis().SetDecimals()
        legSigmaRatio = TLegend(0.4, 0.73, 0.7, 0.93)
        legSigmaRatio.SetFillStyle(0)
        legSigmaRatio.SetBorderSize(0)
        legSigmaRatio.SetTextSize(0.04)
        for hist, color, marker, legend_name in zip(sigma_ratio_list, colors[1:],
                                                    markers[1:], legendnames[1:]):
            SetObjectStyle(hist, linecolor=color, markercolor=color, markerstyle=marker)
            hist.Draw('same')
            legSigmaRatio.AddEntry(hist, legend_name, 'p')
        lineRatio.Draw()
        legSigmaRatio.Draw()
        cMeanRatio.SaveAs(f'{inputdir}/MeanRatio_{suffix}.pdf')
        cSigmaRatio.SaveAs(f'{inputdir}/SigmaRatio_{suffix}.pdf')

    cMean = TCanvas('cMean', '', 800, 800)
    hFrameMean = cMean.DrawFrame(min_pt, massD*0.995, max_pt, massD*1.01,
                                 ';#it{p}_{T} (GeV/#it{c}); peak mean (GeV/#it{c}^{2})')
    hFrameMean.GetYaxis().SetDecimals()
    lineMass.Draw("same")
    for histo_mean in hMean:
        histo_mean.Draw('same')
    legMean.Draw()

    cSigma = TCanvas('cSigma', '', 800, 800)
    cSigma.DrawFrame(min_pt, 0., max_pt, 0.025, ';#it{p}_{T} (GeV/#it{c}); peak width (GeV/#it{c}^{2})')
    for histo_sigma in hSigma:
        histo_sigma.Draw('same')
    legSigma.Draw()

    cMean.SaveAs(f'{inputdir}/Mean_{suffix}.pdf')
    cSigma.SaveAs(f'{inputdir}/Sigma_{suffix}.pdf')
    input('Press enter to exit')
Exemplo n.º 19
0
               markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsSigmaRatioSecondFirstPeak,
               color=kRed,
               markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsSoverBSecPeak, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsSignalSecPeak, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsBkgSecPeak, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsTrue, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRawYieldsSecPeakTrue, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRelDiffRawYieldsFitTrue, color=kRed, markerstyle=kFullSquare)
SetObjectStyle(hRelDiffRawYieldsSecPeakFitTrue,
               color=kRed,
               markerstyle=kFullSquare)

# fit histos
massDplus = TDatabasePDG.Instance().GetParticle(411).Mass()
massDs = TDatabasePDG.Instance().GetParticle(431).Mass()
massForFit = massDplus if fitConfig[cent]['Meson'] == 'Dplus' else massDs

cMass = TCanvas("cMass", "cMass", 1920, 1080)
DivideCanvas(cMass, nPtBins)
cResiduals = TCanvas("cResiduals", "cResiduals", 1920, 1080)
DivideCanvas(cResiduals, nPtBins)

massFitter = []
for iPt, (hM, ptMin, ptMax, reb, sgn, bkg, secPeak, massMin, massMax) in enumerate(zip(
        hMass, ptMins, ptMaxs, fitConfig[cent]['Rebin'], SgnFunc, BkgFunc, \
            inclSecPeak, fitConfig[cent]['MassMin'], fitConfig[cent]['MassMax'])):

    hMassForFit.append(TH1F())
    AliVertexingHFUtils.RebinHisto(hM, reb).Copy(
Exemplo n.º 20
0
parser.add_argument('outFileName', metavar='text', default='outFileName.root',
                    help='output root file name')
args = parser.parse_args()

#config with input file details
with open(args.cfgFileName, 'r') as ymlCfgFile:
    inputCfg = yaml.load(ymlCfgFile, yaml.FullLoader)
inFileNames = inputCfg['filename']
if not isinstance(inFileNames, list):
    inFileNames = [inFileNames]
isMC = inputCfg['isMC']

#define mass binning
meson = inputCfg['tree']['meson']
if meson == 'Ds':
    mD = TDatabasePDG.Instance().GetParticle(431).Mass()
elif meson == 'Dplus':
    mD = TDatabasePDG.Instance().GetParticle(411).Mass()
else:
    print('Error: only Dplus and Ds mesons supported. Exit!')
    exit()

#selections to be applied
with open(args.cutSetFileName, 'r') as ymlCutSetFile:
    cutSetCfg = yaml.load(ymlCutSetFile, yaml.FullLoader)
cutVars = cutSetCfg['cutvars']
selToApply = []
for iPt, _ in enumerate(cutVars['Pt']['min']):
    selToApply.append('')
    for iVar, varName in enumerate(cutVars):
        if varName == 'InvMass':
Exemplo n.º 21
0
    def __init__(self, parse, tree):

        #electron and proton energy, GeV
        self.Ee = parse.getfloat("main", "Ee")
        self.Ep = parse.getfloat("main", "Ep")

        print("Ee, GeV =", self.Ee)
        print("Ep, GeV =", self.Ep)

        #A and Z of the nucleus
        self.A = 1
        self.Z = 1
        if parse.has_option("main", "A"):
            self.A = parse.getint("main", "A")
        if parse.has_option("main", "Z"):
            self.Z = parse.getint("main", "Z")
        print("A:", self.A)
        print("Z:", self.Z)

        #minimal photon energy, GeV
        self.emin = parse.getfloat("main", "emin")
        print("emin, GeV =", self.emin)

        #alpha r_e^2
        self.ar2 = 7.297 * 2.818 * 2.818 * 1e-2  # m barn

        #electron and nucleus mass
        self.me = TDatabasePDG.Instance().GetParticle(11).Mass()
        self.mp = TDatabasePDG.Instance().GetParticle(2212).Mass()
        self.mn = self.A * self.mp

        #nucleus beam vector
        nvec = TLorentzVector()
        pz_a = TMath.Sqrt(self.Ep**2 - self.mp**2) * self.Z
        en_a = TMath.Sqrt(pz_a**2 + self.mn**2)
        nvec.SetPxPyPzE(0, 0, pz_a, en_a)
        print("Nucleus beam gamma:", nvec.Gamma())

        #boost vector of nucleus beam
        self.nbvec = nvec.BoostVector()

        #electron beam vector
        evec = TLorentzVector()
        evec.SetPxPyPzE(0, 0, -TMath.Sqrt(self.Ee**2 - self.me**2), self.Ee)
        print("Electron beam gamma:", evec.Gamma())

        #electron beam energy in nucleus beam rest frame
        evec.Boost(-self.nbvec.x(), -self.nbvec.y(), -self.nbvec.z())
        self.Ee_n = evec.E()

        print("Ee_n, GeV:", self.Ee_n)

        #minimal photon energy in nucleus rest frame
        eminv = TLorentzVector()
        eminv.SetPxPyPzE(0, 0, -self.emin, self.emin)
        eminv.Boost(-self.nbvec.x(), -self.nbvec.y(), -self.nbvec.z())
        emin_n = eminv.E()
        print("emin_n, GeV:", emin_n)

        #maximal delta in nucleus frame
        dmax_n = 100.
        if parse.has_option("main", "dmax_n"):
            dmax_n = parse.getfloat("main", "dmax_n")

        print("dmax_n:", dmax_n)

        #cross section formula
        self.eqpar = self.eq(self)
        self.dSigDwDt = TF2("dSigDwDt", self.eqpar, emin_n, self.Ee_n, 0,
                            dmax_n)
        self.dSigDwDt.SetNpx(2000)
        self.dSigDwDt.SetNpy(2000)
        gRandom.SetSeed(5572323)

        #total integrated cross section over all delta (to 1e5)
        dSigInt = TF2("dSigInt", self.eqpar, emin_n, self.Ee_n, 0, 1e5)
        sigma_tot = dSigInt.Integral(emin_n, self.Ee_n, 0, 1e5)

        print("Total cross section, mb:", sigma_tot)

        #uniform generator for azimuthal angles
        self.rand = TRandom3()
        self.rand.SetSeed(5572323)

        #tree output from the generator
        tlist = ["true_phot_w", "true_phot_delta", "true_phot_theta_n"]
        tlist += ["true_phot_theta", "true_phot_phi", "true_phot_E"]
        tlist += ["true_el_theta", "true_el_phi", "true_el_E"]
        self.tree_out = self.set_tree(tree, tlist)

        print("Lifshitz_93p16 parametrization initialized")
Exemplo n.º 22
0
             ptBinsArr))
    SetObjectStyle(hRawYieldsSignalDiffSigma[iS],
                   color=kBlack,
                   markerstyle=kFullCircle)
    SetObjectStyle(hRawYieldsBkgDiffSigma[iS],
                   color=kBlack,
                   markerstyle=kFullCircle)
    SetObjectStyle(hRawYieldsSoverBDiffSigma[iS],
                   color=kBlack,
                   markerstyle=kFullCircle)
    SetObjectStyle(hRawYieldsSignifDiffSigma[iS],
                   color=kBlack,
                   markerstyle=kFullCircle)

# fit histos
massDplus = TDatabasePDG.Instance().GetParticle(411).Mass()
massDs = TDatabasePDG.Instance().GetParticle(431).Mass()
massLc = TDatabasePDG.Instance().GetParticle(4122).Mass()
massDstar = TDatabasePDG.Instance().GetParticle(
    413).Mass() - TDatabasePDG.Instance().GetParticle(421).Mass()
massD0 = TDatabasePDG.Instance().GetParticle(421).Mass()

if particleName == 'Dplus':
    massForFit = massDplus
elif particleName == 'Ds':
    massForFit = massDs
elif particleName == 'Dstar':
    massForFit = massDstar
elif particleName == 'D0':
    massForFit = massD0
else: