Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
#%%
#######################################
# This is the main cicle.
# It generates replica of data take random PDF and minimize it
# Save to log.
#######################################
for i in range(StartReplica, FinalReplica + 1):
    print('---------------------------------------------------------------')
    print('------------REPLICA ', i, ' from [', StartReplica, ' , ',
          FinalReplica, ']------------------')
    print('---------------------------------------------------------------')

    ## reset PDF
    harpy.setNPparameters(initializationArray)
    harpy.setPDFreplica(i)
    SaveToLog("Start computation of replica " + str(i) + "in [" +
              str(StartReplica) + ',' + str(FinalReplica) + "]")

    ## got to pseudo-data and minimization
    repRes = MinForReplica()
    print(repRes)
    SaveToLog("Minimization for replica " + str(i) + "in [" +
              str(StartReplica) + ',' + str(FinalReplica) + "] finished.")

    ## compute the chi2 for true data
    mainDY, mainDY2 = DataProcessor.harpyInterface.ComputeChi2(setDY)
    SaveToLog("Central chi^2 for " + str(i) + "in [" + str(StartReplica) +
              ',' + str(FinalReplica) + " computed. \n Saving to log >> " +
              replicaFile)
def setReplica(n):
    line = PDFrep[n]
    harpy.setPDFreplica(line[3])
    harpy.setNPparameters(line[4])
Exemplo n.º 5
0
#%%
import ast

replicas=[]
for l in data_from_f:
    replicas.append(ast.literal_eval(l))


#%%
f = open("/misc/data2/braun/vla18041/WorkingFiles/TMD/Fit_Notes/TMD<->PDF/LOGS/NNPDF31/allPDF_centralEXP_full_POINTStest.dat",'a')
f.write(str([p["id"] for p in setDY.points]))
f.write("\n")
f.close()
#%%

for j in range(655,867):    
    r=replicas[j]
    print('>>> DOING >>>> ',j,'  = ',r[3])    
    harpy.setPDFreplica(r[3])
    harpy.setNPparameters(r[4])
    YY=DataProcessor.harpyInterface.ComputeXSec(setDY)
    RR=[]
    for i in range(len(YY)):
        p=setDY.points[i]
        RR.append((p["xSec"]-YY[i])**2/numpy.dot(p["uncorrErr"],p["uncorrErr"]))
    
    f = open("/misc/data2/braun/vla18041/WorkingFiles/TMD/Fit_Notes/TMD<->PDF/LOGS/NNPDF31/allPDF_centralEXP_full_POINTStest.dat",'a')
    f.write(str(RR))
    f.write("\n")
    f.close()
    
Exemplo n.º 6
0
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])
            ubar2.append(tmd[5 - 2])
    def SetReplica(self, num=0, part='full'):
        """
        Set the replica according to the list

        Parameters
        ----------
        num : -1 = initla replica
              0  = mean replica
              1.... = replica from list
            The default is 0.
        
        part : string, optional
            Specification which part of the replica to be set. The default is "full".
            Possible values: 'full', 'TMDR', 'uTMDPDF', 'uTMDFF', 'lpTMDPDF', 'SiversTMDPDF', etc

        Returns
        -------
        None.

        """
        import harpy

        if (num == 0):
            r = self.meanReplica
        elif (num == -1):
            r = self.initialReplica
        else:
            r = self.replicaList[num - 1]

        ## resolvinf the part-condition
        if (part == "full"):
            doTMDR = True
            douTMDPDF = True
            douTMDFF = True
            dolpTMDPDF = True
            doSiversTMDPDF = True
        else:
            doTMDR = False
            douTMDPDF = False
            douTMDFF = False
            dolpTMDPDF = False
            doSiversTMDPDF = False

            if (part == 'TMDR'):
                doTMDR = True
            if (part == 'uTMDPDF'):
                douTMDPDF = True
            if (part == 'uTMDFF'):
                douTMDFF = True
            if (part == 'lpTMDPDF'):
                dolpTMDPDF = True
            if (part == 'SiversTMDPDF'):
                doSiversTMDPDF = True

        if (doTMDR and self._TMDRend >= self._TMDRstart + 1 > 0):
            harpy.setNPparameters_TMDR(r[self._TMDRstart:self._TMDRend])

        if (douTMDPDF and self._uTMDPDFend >= self._uTMDPDFstart + 1 > 0):
            if (self._c_uTMDPDFend >= self._c_uTMDPDFstart + 1 > 0):
                harpy.setPDFreplica(r[self._c_uTMDPDFstart])
            harpy.setNPparameters_uTMDPDF(
                r[self._uTMDPDFstart:self._uTMDPDFend])

        if (douTMDFF and self._uTMDFFend >= self._uTMDFFstart + 1 > 0):
            if (self._c_uTMDFFend >= self._c_uTMDFFstart + 1 > 0):
                print("Modification of FF replica is not implimented")
            harpy.setNPparameters_uTMDFF(r[self._uTMDFFstart:self._uTMDFFend])

        if (dolpTMDPDF and self._lpTMDPDFend >= self._lpTMDPDFstart + 1 > 0):
            if (self._c_lpTMDPDFend >= self._c_lpTMDPDFstart + 1 > 0):
                print("Modification of lpPDF replica is not implimented")
            harpy.setNPparameters_lpTMDPDF(
                r[self._lpTMDPDFstart:self._lpTMDPDFend])

        if (doSiversTMDPDF
                and self._SiversTMDPDFend >= self._SiversTMDPDFstart + 1 > 0):
            if (self._SiversTMDPDFend >= self._SiversTMDPDFstart + 1 > 0):
                print("Modification of Sivers replica is not implimented")
            harpy.setNPparameters_SiversTMDPDF(
                r[self._SiversTMDPDFstart:self._SiversTMDPDFend])
Exemplo n.º 8
0
#%%
#######################################
# This is the main cicle.
# It generates replica of data take random PDF and minimize it
# Save to log.
#######################################
for i in range(numOfReplicas):
    print('---------------------------------------------------------------')
    print('------------REPLICA ', i, '/', numOfReplicas,
          '--------------------')
    print('---------------------------------------------------------------')

    ## reset PDF
    harpy.setNPparameters(initializationArray)
    numPDF = numpy.random.randint(1, 1001)
    harpy.setPDFreplica(numPDF)
    SaveToLog("Start computation of replica " + str(i) + "/" +
              str(numOfReplicas) + " with PDF replica " + str(numPDF))

    ## got to pseudo-data and minimization
    repRes = MinForReplica()
    print(repRes)
    SaveToLog("Minimization for replica " + str(i) + "/" + str(numOfReplicas) +
              " finished.")

    ## compute the chi2 for true data
    mainDY, mainDY2 = DataProcessor.harpyInterface.ComputeChi2(setDY)
    SaveToLog("Central chi^2 for " + str(i) + "/" + str(numOfReplicas) +
              " computed. \n Saving to log >> " + replicaFile)

    ## save to file