def chi_2(x): startT = time.time() harpy.setNPparameters(x) print('np set =', ["{:8.3f}".format(i) for i in x], end=" ") ccSIDIS2, cc3 = DataProcessor.harpyInterface.ComputeChi2(setSIDIS) cc = ccSIDIS2 / totalN endT = time.time() print(':->', cc, ' t=', endT - startT) return ccSIDIS2
def CorrelationParameters(pN, deltap): import copy Npoints = 50 vectorO = [] vectorF1 = [] n1 = 0 n2 = 0 ## compute xSec for each of parameters for n in range(Npoints): #param=pMin+n/(Npoints-1)*(pMin-pMax) param = numpy.abs(numpy.random.normal(initialValues[pN], deltap)) NPparams = copy.copy(list(initialValues)) NPparams[pN] = param harpy.setNPparameters(NPparams) ### vector of cross-section XX1 = DataProcessor.harpyInterface.ComputeXSec(setDY) ### vector of test function F1 = [] for p in setDY.points: F1.append(param) vectorO.append(XX1) vectorF1.append(F1) n1 += 1 n2 += 1 if (n1 > (Npoints / 10.)): n1 = 0 print(n2 / (Npoints + 1) * 100., ' %') vectorO = numpy.array(vectorO) vectorF1 = numpy.array(vectorF1) ### <xSec * p> avOF1 = numpy.mean(numpy.multiply(vectorO, vectorF1), axis=0) ### <xSec> avO = numpy.mean(vectorO, axis=0) ### <p> avF1 = numpy.mean(vectorF1, axis=0) ### delta xSec stdO = numpy.std(vectorO, axis=0) ### delta p stdF1 = numpy.std(vectorF1, axis=0) ### correlation (<xSec * p>- <xSec><p>)/deltaXsec/deltap rho1 = numpy.divide(avOF1 - numpy.multiply(avO, avF1), numpy.multiply(stdO, stdF1)) return numpy.transpose([rho1, stdO, avO])
def SetReplicaEntry(n): import ast fp = open(PathToReplicaFile,"r") for i, line in enumerate(fp): if i == n-1: entry=ast.literal_eval(line) harpy.setPDFreplica(entry[3]) harpy.setNPparameters(entry[4]) elif i > n: break fp.close()
def repchi_2(x): global totalN startT = time.time() harpy.setNPparameters(x) print('np set =', ["{:8.3f}".format(i) for i in x], end=" ") ccDY2, cc2 = DataProcessor.harpyInterface.ComputeChi2(repDataDY) cc = (ccDY2) / totalN endT = time.time() print(':->', cc, ' t=', endT - startT) return ccDY2
def chi_2(x): startT=time.time() harpy.setNPparameters(x) print('np set =',["{:8.3f}".format(i) for i in x], end =" ") ccDY2,cc3=DataProcessor.harpyInterface.ComputeChi2(setDY) if(usePenaltyTerm): ccDY2+=totalN*PenaltyTerm(x) cc=ccDY2/totalN endT=time.time() print(':->',cc,' t=',endT-startT) return ccDY2
def SavePlot0(n): harpy.setPDFreplica(n) harpy.setNPparameters(CentralReplica) plot=[] for x in xValues: for b in bValues: pp=harpy.get_uTMDPDF(x,b,1) plot.append([x,b,list(pp)]) print(PathToSavePlot+"/"+fileName+"_"+str(n)) fp = open(PathToSavePlot+"/"+fileName+"_"+str(n)+".dat","w") for line in plot: fp.write(str(line)+"\n") fp.close()
# importing libraries ####################################### import numpy import DataProcessor.harpyInterface import DataProcessor.DataMultiSet #%% ####################################### #Initialize artemide ####################################### import harpy harpy.initialize(PathToConstantsFile) initializationArray = [2.0340, 0.0299, 0.1, 2., 0.1, 2., 0.1, 1., 10000.] harpy.setNPparameters(initializationArray) #%% ####################################### # Data cut function ####################################### def cutFunc(p): delta = p["<qT>"] / p["<Q>"] if (p["id"][0] == "E"): delta = p["<qT>"] / p["Q"][1] if (p["id"][0:4] == "E605"): if (p["Q"][0] == 10.5): #UPSILON resonance-bin return False, p
savedTime = time.time() #%% ####################################### #Initialize artemide ####################################### import harpy SaveToLog('Initialization with : \n' + PathToConstantsFile) harpy.initialize(PathToConstantsFile) initializationArray = [ 2.0340, 0.0299, 0.2512, 7.7572, 334.6108, 2.4543, -4.8203, 0.1000, 0.0000 ] harpy.setNPparameters(initializationArray) #%% ####################################### # read the list of files and return the list of DataSets ####################################### def loadThisData(listOfNames): import DataProcessor.DataSet dataCollection = [] for name in listOfNames: loadedData = DataProcessor.DataSet.LoadCSV(PathToDataLibrary + name + ".csv") dataCollection.append(loadedData)
#%% for s in setDY.sets: if s.isNormalized: #s.normalizationMethod="bestChi2" s.normalizationMethod = "integral" #%% #harpy.setNPparameters([1.92819, 0.0390534, 0.198279, 9.29836, 431.647, 2.11829, -4.44162, 0., 0., 0.259499, 0.476235, 0.477143, 0.482977]) ##NNPDF+DSS (paper) #harpy.setNPparameters([1.92516, 0.0426578, 0.223809, 9.23868, 375.888, 2.14611, -4.97177, 0., 0., 0.233382, 0.478562, 0.47218, 0.511187]) ##NNPDF+DSS n3lo (paper) ##NNPDF+DSS (paper) pi/K harpy.setNPparameters([ 2., 0.0397287, 0.180468, 4.33024, 423.481, 2.22637, -0.0862019, 0., 0., 0.291174, 0.461295, 0.444895, 0.581916, 0.428639, 0.457899, 0.295924, 1.22788 ]) # harpy.setNPparameters([2., 0.0396753, 0.185239, 6.22706, 580.946, 2.44166, -2.53161, 0., 0., # 0.279443, 0.460015, 0.435955, 0.551302, # 0.279443, 0.460015, 0.435955, 0.551302 ]) DataProcessor.harpyInterface.PrintChi2Table(setDY, printDecomposedChi2=True) #DataProcessor.harpyInterface.PrintChi2Table(setSIDIS,printDecomposedChi2=True) #%% ####################################### # Minimisation ####################################### totalN = setDY.numberOfPoints + setSIDIS.numberOfPoints
MAINPATH = "/home/vla18041/LinkData2/arTeMiDe_Repository/DataProcessor/" #%% ####################################### #Initialize artemide with a replica -2 ####################################### import harpy path_to_constants = MAINPATH + "FittingPrograms/SV19/Constants-files/" #harpy.initialize(path_to_constants+"DY_n3lo/const-NNPDF31_n3lo") #harpy.initialize(path_to_constants+"DY_nnlo/const-HERA20_NNLO") #harpy.initialize(path_to_constants+"DY_n3lo/const-HERA20_n3lo") #harpy.initialize(path_to_constants+"DY_nnlo/const-MMHT14_NNLO") #harpy.initialize(path_to_constants+"DY_nnlo/const-CT14_NNLO") #harpy.initialize(path_to_constants+"DY_nnlo/const-PDF4LHC_NNLO") harpy.setNPparameters([ 2.0340, 0.0299, 0.2512, 7.7572, 334.6108, 2.4543, -4.8203, 0.1000, 0.0000 ]) #harpy.setNPparameters_TMDR(-2) #harpy.setNPparameters_uTMDPDF(-2) #%% ### read the list of files and return the list of DataSets def loadThisData(listOfNames): import DataProcessor.DataSet path_to_data = "/home/vla18041/LinkData2/arTeMiDe_Repository/DataProcessor/DataLib/unpolDY/" dataCollection = [] for name in listOfNames:
setSIDIS = theData.CutData(cutFunc) print('Loaded ', setSIDIS.numberOfSets, 'data sets with', sum([i.numberOfPoints for i in setSIDIS.sets]), 'points.') print('Loaded experiments are', [i.name for i in setSIDIS.sets]) #%% #harpy.setNPparameters([1.92819, 0.0390534, 0.198279, 9.29836, 431.647, 2.11829, -4.44162, 0., 0., 0.259499, 0.476235, 0.477143, 0.482977]) ##NNPDF+DSS (paper) #harpy.setNPparameters([1.92516, 0.0426578, 0.223809, 9.23868, 375.888, 2.14611, -4.97177, 0., 0., 0.233382, 0.478562, 0.47218, 0.511187]) ##NNPDF+DSS n3lo (paper) ##NNPDF+DSS (paper) pi/K harpy.setNPparameters([ 1.92819, 0.0390534, 0.198279, 9.29836, 431.647, 2.11829, -4.44162, 0., 0., 0.259499, 0.476235, 0.477143, 0.482977, 0.259499, 0.476235, 0.477143, 0.482977 ]) DataProcessor.harpyInterface.PrintChi2Table(setSIDIS, printDecomposedChi2=True) #%% ####################################### # Minimisation ####################################### totalN = setSIDIS.numberOfPoints def chi_2(x): startT = time.time() harpy.setNPparameters(x)
def setReplica(n): line = PDFrep[n] harpy.setPDFreplica(line[3]) harpy.setNPparameters(line[4])
print('Loaded ', setDY.numberOfSets, 'data sets with', sum([i.numberOfPoints for i in setDY.sets]), 'points.') print('Loaded experiments are', [i.name for i in setDY.sets]) print('Loaded ', setSIDIS.numberOfSets, 'data sets with', sum([i.numberOfPoints for i in setSIDIS.sets]), 'points.') print('Loaded experiments are', [i.name for i in setSIDIS.sets]) #%% #harpy.setNPparameters([1.93, 0.0434,0.195, 9.117, 444., 2.12, -4.89,0.,0.,0.258, 0.478, 0.484, 0.459]) ##NNPDF+DSS #harpy.setNPparameters([2.2764,0.0223, 0.3237, 13.17, 355.4, 2.049, -10.43,0.,0.,0.264, 0.479,0.459,0.539]) ##HERA+DSS #harpy.setNPparameters([1.92819, 0.0390534, 0.198279, 9.29836, 431.647, 2.11829, -4.44162, 0., 0., 0.259499, 0.476235, 0.477143, 0.482977]) ##NNPDF+DSS (paper) #harpy.setNPparameters([1.92516, 0.0426578, 0.223809, 9.23868, 375.888, 2.14611, -4.97177, 0., 0., 0.233382, 0.478562, 0.47218, 0.511187]) ##NNPDF+DSS n3lo (paper) ##NNPDF+DSS (paper) M=0 harpy.setNPparameters([2., 0.0405, 0.188, 7.46, 532., 2.27, -2.59, 0., 0.,0.264,0.479, 0.0, 0.0, 1.5, 0.539]) #harpy.setNPparameters([2., 0.0405, 0.188, 7.46, 532., 2.27, -2.59, 0., 0.,0.198, 0.473, 0.509, 0.413,0.198, 0.473, 0.509, 0.413]) #DataProcessor.harpyInterface.PrintChi2Table(setDY,printDecomposedChi2=True) DataProcessor.harpyInterface.PrintChi2Table(setSIDIS,printDecomposedChi2=True) #%% ####################################### # Minimisation ####################################### #totalN=setDY.numberOfPoints+setSIDIS.numberOfPoints totalN=setDY.numberOfPoints+setSIDIS.numberOfPoints def chi_2(x): startT=time.time() harpy.setNPparameters(x)
####################################### import socket PCname=socket.gethostname() replicaFile=PathToLog+"SV19_NNPDF31_pointsTEST.txt" logFile=PathToLog+PCname+".log" #%% ####################################### #Initialize artemide ####################################### import harpy harpy.initialize(PathToConstantsFile) initializationArray=[2.0340, 0.0299, 0.2512, 7.7572,334.6108, 2.4543,-4.8203, 0.1000, 0.0000] harpy.setNPparameters(initializationArray) #%% ####################################### # read the list of files and return the list of DataSets ####################################### def loadThisData(listOfNames): import DataProcessor.DataSet dataCollection=[] for name in listOfNames: loadedData=DataProcessor.DataSet.LoadCSV(PathToDataLibrary+name+".csv") dataCollection.append(loadedData) return dataCollection
####################################### mu = -1. u = [] d = [] s = [] ubar = [] dbar = [] sbar = [] for i in range(len(replicas)): print('-------------------------', i, '/', len(replicas), '-----------------------------') #harpy.setNPparameters(replicas[i][4]) harpy.setNPparameters( [2.000, 0.036, 0.089, 8.657, 0.389, 0.000, 0.465, 6.195, 527.903]) harpy.setPDFreplica(replicas[i][3]) u2 = [] d2 = [] s2 = [] ubar2 = [] dbar2 = [] sbar2 = [] for x in xValues: for b in bValues: tmd = harpy.get_uTMDPDF(x, b, 1, mu=mu) u2.append(tmd[5 + 2]) d2.append(tmd[5 + 1]) s2.append(tmd[5 + 3])
sys.path.append("/home/vla18041/LinkData2/arTeMiDe_Repository/DataProcessor") import DataProcessor.harpyInterface import DataProcessor.ArtemideReplicaSet import DataProcessor.DataMultiSet MAINPATH = "/home/vla18041/LinkData2/arTeMiDe_Repository/DataProcessor/" #%% ####################################### #Initialize artemide with a replica -2 ####################################### import harpy path_to_constants = MAINPATH + "FittingPrograms/SV19/Constants-files/" harpy.initialize(path_to_constants + "DY_nnlo/const-NNPDF31_NNLO") harpy.setNPparameters([ 2.0340, 0.0299, 0.2512, 7.7572, 334.6108, 2.4543, -4.8203, 0.1000, 0.0000 ]) #%% ### read the list of files and return the list of DataSets import DataProcessor.DataSet data = DataProcessor.DataSet.LoadCSV( "/home/vla18041/LinkData2/arTeMiDe_Repository/DataProcessor/OtherPrograms/Predictions/ATLAS8/A8-predict.csv" ) ############## I drop all points after ~0.25, last two bins are not trastful def cutFunc(p): return p["<qT>"] < 25.5, p
setPLOT = theData.CutData(cutFuncPlot) print('SV21: Loaded ', setSV21.numberOfSets, 'data sets with ', sum([i.numberOfPoints for i in setSV21.sets]), 'points.') print('SV19: Loaded ', setSV19.numberOfSets, 'data sets with ', sum([i.numberOfPoints for i in setSV19.sets]), 'points.') print('PLOT: Loaded ', setPLOT.numberOfSets, 'data sets with ', sum([i.numberOfPoints for i in setPLOT.sets]), 'points.') #%% if (PDFinUse == "MSHT20"): harpy.setNPparameters([ 2., 0.0435856, 0.120811, 0.316864, 0.366887, 1.6959, 0.00369852, 56.4383, 0.00123501, 1.09761, 0.107047, 5.07336, 28.6827, 0 ]) if (PDFinUse == "HERA20"): harpy.setNPparameters([ 2., 0.0326349, 0.105422, 8.15213, 0.442909, 0.109655, 0.11605, 6.52881, 0.34749, 0.0498677, 0.491896, 5.22109, 336.538, 0 ]) if (PDFinUse == "NNPDF31"): harpy.setNPparameters([ 2., 0.026075, 0.284306, 2.57804, 0.398623, 1.10417, 0.0874515, 12.5858, 0.0981801, 6.05093, 0.251195, 3.00048, 180.76, 0 ]) if (PDFinUse == "CT18"):
print('Loaded ', setDY.numberOfSets, 'data sets with', sum([i.numberOfPoints for i in setDY.sets]), 'points.') print('Loaded experiments are', [i.name for i in setDY.sets]) print('Loaded ', setSIDIS.numberOfSets, 'data sets with', sum([i.numberOfPoints for i in setSIDIS.sets]), 'points.') print('Loaded experiments are', [i.name for i in setSIDIS.sets]) #SaveToLog('Loaded '+ str(setDY.numberOfSets) + ' data sets with '+str(sum([i.numberOfPoints for i in setDY.sets])) + ' points. \n' #+'Loaded experiments are '+str([i.name for i in setDY.sets])) #%% harpy.setNPparameters([ 1.93, 0.0434, 0.195, 9.117, 444., 2.12, -4.89, 0., 0., 0.258, 0.478, 0.484, 0.459 ]) ##NNPDF+DSS #harpy.setNPparameters([2.2764,0.0223, 0.3237, 13.17, 355.4, 2.049, -10.43,0.,0.,0.264, 0.479,0.459,0.539]) ##HERA+DSS #harpy.setNPparameters([1.92819, 0.0390534, 0.198279, 9.29836, 431.647, 2.11829, -4.44162, 0., 0., 0.259499, 0.476235, 0.477143, 0.482977]) ##NNPDF+DSS (paper) #harpy.setNPparameters([1.92516, 0.0426578, 0.223809, 9.23868, 375.888, 2.14611, -4.97177, 0., 0., 0.233382, 0.478562, 0.47218, 0.511187]) ##NNPDF+DSS n3lo (paper) ##NNPDF+DSS M=0 #harpy.setNPparameters([2., 0.0405, 0.188, 7.46, 532., 2.27, -2.59, 0., 0.,0.198, 0.473, 0.509, 0.413]) ##NNPDF+DSS all=0 #harpy.setNPparameters([2., 0.044, 0.187, 5.936, 647., 2.518, -2.94, 0., 0.,0.283, 0.463, 0.446, 0.528]) ## NNPDF+DSS all=0 # harpy.setNPparameters_TMDR([2., 0.0398333]) # harpy.setNPparameters_uTMDPDF([0.184739, 6.22437, 588.193, 2.44327, -2.51106, 0., 0.]) # harpy.setNPparameters_uTMDFF([0.277974, 0.459238, 0.43427, 0.55001])