示例#1
0
productionAmplitudes=[]

waves=getwaves(os.path.join(dataDir,"flat"))

normint=numpy.load(os.path.join(dataDir,"flat","normint.npy"))

if os.path.isfile(os.path.join(dataDir,"Vvalues.npy")):
    contents=numpy.load(os.path.join(dataDir,"Vvalues.npy"))    
    orderedContents=sorted(contents.tolist().iteritems(),key=operator.itemgetter(0))     
    for i in range(0,len(orderedContents),2):
        realPart=orderedContents[i][1]
        imaginaryPart=orderedContents[i+1][1]
        productionAmplitudes.append(numpy.complex(realPart,imaginaryPart))
    if sys.argv[3] == "s":
        nTrueList = [ntrue(productionAmplitudes,waves,normint)]  
        for wave in waves:
            nTrueList.append(wave.filename.rstrip(".bamp"))
            nTrueList.append(ntrueforwave(productionAmplitudes[waves.index(wave)],waves,wave,normint).real)        
        numpy.save(os.path.join(dataDir,"flat","nTrueListV.npy"),nTrueList)       
elif os.path.isfile(os.path.join(topDir,"scripts","resonances.txt")):
    resonances=[]
    res = open(os.path.join(topDir,"scripts","resonances.txt"))
    rez = res.readlines()
    for re in rez:
        if re[0] != "#" and re[0] != " " and re[0] != "\n":
            rev = re.split()
            wRx = [(float(x)) for x in rev[1].split(",")]
            resonances.append(resonance(cR=float(rev[0])*maxNumberOfEvents,wR=wRx,w0=float(rev[2]),r0=float(rev[3]),phase=float(rev[4])))        
    if sys.argv[3] == "s":
        nTrueList = [ntrue(resonances,waves,testMass,normint)]  
示例#2
0
文件: runNTrue.py 项目: bdell/pyPWA
from pythonPWA.fileHandlers.getWavesGen import getwaves
from pythonPWA.model.normInt import normInt
from pythonPWA.model.intensity import intensity
from pythonPWA.fileHandlers.gampReader import gampReader
from pythonPWA.utilities.dataSimulator import dataSimulator
from pythonPWA.model.nTrue import nTrueForFixedV1V2 as ntrue
from pythonPWA.model.nTrue import nTrueForFixedV1V2AndWave as ntrueforwave

dataDir=os.path.join("/","home","salgado","pkk","data","1000pd_MeV")
print"working with dataDir=",dataDir
    
waves=getwaves(dataDir)
print"loaded",len(waves),"waves"

accNormInt=numpy.load(os.path.join(dataDir,"mc","normint.npy"))

v1=numpy.complex(-0.1759968798932109,-0.06703609562678432)

v2=numpy.complex(0.056361107762924675,-0.1377034355817562)

print"nTrue:", ntrue([v1,v2],waves,accNormInt)

vList=[v1,v2]

nTrueList=[]

for wave in waves:
    print"for wave",waves.index(wave),"ntrue=",ntrueforwave(vList[waves.index(wave)],waves,wave,accNormInt)
    nTrueList.append(ntrueforwave(vList[waves.index(wave)],waves,wave,accNormInt))
    
print"wave0/wave1=",nTrueList[0]/nTrueList[1]
示例#3
0
def calcNTrueForDir(dataDir): 
    """
        This function calculates the value of the total nTrue and the nTrue values for each wave for a single mass bin directory.

        Args:
        dataDir (string): The complete file path to the "mass_MeV" directory.
    """
       
    #list to hold nTrue errors
    errorList=[]
    errorListEx=[]
    wvNameList=[]
    #getting our waves
    waves=getwaves(os.path.join(dataDir,"data"))        
    #loading our accepted normalization integral (NOTE: its from the mc directory)
    accNormInt=numpy.load(os.path.join(dataDir,"mc","acc","normint.npy"))
    rawNormInt=numpy.load(os.path.join(dataDir,"mc","raw","normint.npy"))    
    apath = os.path.join(dataDir,"mc","acc","alphaevents.txt")
    rpath = os.path.join(dataDir,"mc","raw","alphaevents.txt")
    #apath = os.path.join(dataDir,"mc","acc","events.num")
    #rpath = os.path.join(dataDir,"mc","raw","events.num")
    #instantiating our list of complex production amplitudes, should be
    ##a list of 2 numpy complexes
    contents=numpy.load(os.path.join(dataDir,"Vvalues.npy"))    
    orderedContents=sorted(contents.tolist().iteritems(),key=operator.itemgetter(0))    
    vList=[]
    for i in range(0,len(orderedContents),2):
        realPart=orderedContents[i][1]
        imaginaryPart=orderedContents[i+1][1]
        vList.append(numpy.complex(realPart,imaginaryPart))         
    #calculating nTrue for both waves combined
    ntrueVal=ntrue(vList,waves,rawNormInt)       
    nExpVal=nExp(vList,waves,accNormInt,apath,rpath)    

    nTrueList=[]    
    nExpList=[]
    #then storing it
    nTrueList.append(ntrueVal)
    nExpList.append(nExpVal)
    #next calculating nTrue for each wave
    for wave in waves:
        nTrueList.append(ntrueforwave(vList[waves.index(wave)],waves,wave,rawNormInt).real)    
        nExpList.append(nExpforwave(vList[waves.index(wave)],waves,wave,accNormInt,apath,rpath).real)
        wvNameList.append(wave.filename)

    #next up lets load our raw normalization integral
      
    #loading our minuit covariance matrix obtained from fitting
    if os.path.isfile(os.path.join(dataDir,"minuitCovar3.npy")):
        covarianceMatrix=numpy.load(os.path.join(dataDir,"minuitCovar3.npy"))
        statSquared=calcStatSquaredError(covarianceMatrix,rawNormInt,vList,waves)
        statSquaredEx=calcStatSquaredError(covarianceMatrix,accNormInt,vList,waves)
        print statSquared
        print statSquaredEx
        errorList.append(numpy.sqrt(statSquared[0,0].real))
        errorListEx.append(numpy.sqrt(statSquaredEx[0,0].real))
    if not os.path.isfile(os.path.join(dataDir,"minuitCovar3.npy")):
        statSquared=0
        errorList.append(0)
        statSquaredEx=0
        errorListEx.append(0)
    for wave in waves:
        if statSquared != 0:
            buffer=numpy.zeros(shape=rawNormInt.shape)
            i=waves.index(wave)
            buffer[wave.epsilon,wave.epsilon,i,:]=rawNormInt[wave.epsilon,wave.epsilon,i,:]
            statSquared=calcStatSquaredError(covarianceMatrix,buffer,vList,waves)        
            errorList.append(numpy.sqrt(statSquared[0,0].real))
            buffer=numpy.zeros(shape=accNormInt.shape)
            i=waves.index(wave)
            buffer[wave.epsilon,wave.epsilon,i,:]=accNormInt[wave.epsilon,wave.epsilon,i,:]
            statSquared=calcStatSquaredError(covarianceMatrix,buffer,vList,waves)        
            errorListEx.append(numpy.sqrt(statSquared[0,0].real))
        else:
            errorList.append(0)        
            errorListEx.append(0)  
    #saving our results to be used in plotting later.  format is numpy array [[nTrueTotal,nTrueWave1,nTrueWave2],[errorNTrueTotal,errorNTrueWave1,errorNTrueWave2]]
    #numpy.save(os.path.join(dataDir,"nTrueError.npy"),numpy.array([nTrueList,errorList]))
    retList=[]
    for i in range(len(nTrueList)):
        if i == 0:
            retList.append([dataDir.strip("_MeV"),nTrueList[i],errorList[i],nExpList[i],errorListEx[i]])
        elif i > 0:
            retList.append([dataDir.strip("_MeV"),nTrueList[i],errorList[i],wvNameList[i-1],nExpList[i],errorListEx[i]])
    return retList
示例#4
0
productionAmplitudes=[]

waves=getwaves(os.path.join(dataDir,"flat"))

normint=numpy.load(os.path.join(dataDir,"flat","normint.npy"))

if os.path.isfile(os.path.join(dataDir,"Vvalues.npy")):
    contents=numpy.load(os.path.join(dataDir,"Vvalues.npy"))    
    orderedContents=sorted(contents.tolist().iteritems(),key=operator.itemgetter(0))     
    for i in range(0,len(orderedContents),2):
        realPart=orderedContents[i][1]
        imaginaryPart=orderedContents[i+1][1]
        productionAmplitudes.append(numpy.complex(realPart,imaginaryPart))
    if sys.argv[3] == "s":
        nTrueList = [ntrue(productionAmplitudes,waves,normint)]  
        for wave in waves:
            nTrueList.append(wave.filename.rstrip(".bamp"))
            nTrueList.append(ntrueforwave(productionAmplitudes[waves.index(wave)],waves,wave,normint).real)        
        numpy.save(os.path.join(dataDir,"flat","nTrueListV.npy"),nTrueList)       
elif os.path.isfile(os.path.join(topDir,"scripts","resonances.txt")):
    resonances=[]
    res = open(os.path.join(topDir,"scripts","resonances.txt"))
    rez = res.readlines()
    for re in rez:
        if re[0] != "#" and re[0] != " " and re[0] != "\n":
            rev = re.split()
            wRx = [(float(x)) for x in rev[1].split(",")]
            resonances.append(resonance(cR=float(rev[0])*maxNumberOfEvents,wR=wRx,w0=float(rev[2]),r0=float(rev[3]),phase=float(rev[4])))        
    if sys.argv[3] == "s":
        nTrueList = [ntrue(resonances,waves,testMass,normint)]