Exemplo n.º 1
0
    def MakeConfusionMatrix(self, Name, OutPreOther, OutPreSame):
        train, test = self.DataSet.GetInput(Name)
        cmOther, cmSame = confusion_matrix(test.MultiClass,
                                           OutPreOther), confusion_matrix(
                                               train.MultiClass, OutPreSame)
        cmOther = np.array(cmOther, dtype=np.float32)
        cmSame = np.array(cmSame, dtype=np.float32)
        for row in range(cmOther.shape[0]):
            if (np.sum(cmOther[row] != 0)):
                cmOther[row] = cmOther[row] / np.sum(cmOther[row])
        for row in range(cmSame.shape[0]):
            if (np.sum(cmSame[row] != 0)):
                cmSame[row] = cmSame[row] / np.sum(cmSame[row])

        if (cmOther.shape[0] == 14):
            Names = [
                'tttt', 'others', 'vjets', 'vv', 'tt(X)', 'tt others',
                'tt light', 'tt HF', 'tt CO', 'tt Qmis', 'ttH', 'ttZ', 'ttWW',
                'ttW'
            ]
        elif (cmOther.shape[0] == 3):
            Names = ['tttt', 'ttV', 'rest']
        elif (cmOther.shape[0] == 2):
            Names = ['tttt', 'Bkg']
        PlotService.ConfusionMatrix(cmOther, Names, len(Names), tag='Other')
        PlotService.ConfusionMatrix(cmSame, Names, len(Names), tag='Same')
Exemplo n.º 2
0
    def MakePlots(self, OutPreOther, OutPreSame):
        """ Plotting the ROC, Score of the Model """
        AucOthers, AucSames = [], []
        PlotService.RocCurve("./",OutPreOther,self.DataSet,self.ModelNames)
        if(len(self.ModelNames) == 1):
            AucOther, AucSame = PlotService.Score("./",OutPreOther[0],OutPreSame[0],self.DataSet,self.ModelNames[0])
        elif(len(self.ModelNames) > 1):
            for i,Name in enumerate(self.ModelNames):
                AucOther, AucSame = PlotService.Score("./",OutPreOther[i],OutPreSame[i],self.DataSet,Name)
        AucOthers.append(AucOther)
        AucSames.append(AucSame)            

        return AucOthers, AucSames
Exemplo n.º 3
0
 def PreTrainedFNN(self):
     LOutPreOther = []
     for Name in self.ModelNames:
         OutPreOther, OutPreSame = self.GetOutPreFromFile(Name)
         PreLabelsOther, PreLabelsSame = self.PredictClasses(
             OutPreOther, OutPreSame)
         #self.MakeConfusionMatrix(Name, PreLabelsOther, PreLabelsSame)
         Classnum = 13
         PlotService.MultiScore("./plots/", OutPreOther[:, Classnum],
                                OutPreSame[:, Classnum], self.DataSet, Name,
                                Classnum)  #Score for Sig
         PlotService.Score("./plots/", OutPreOther[:, Classnum],
                           OutPreSame[:, Classnum], self.DataSet, Name)
         #Fit(OutPreOther)
         LOutPreOther.append(OutPreOther[:, 0])
     PlotService.RocCurve("./plots/", LOutPreOther, self.DataSet,
                          self.ModelNames)
Exemplo n.º 4
0
def Fit(OutPre):
    V = 'HT_all'
    Var = [V]
    Utils.stdinfo("Getting the variable from the root file")
    ListSamples = DIClasses.Init(Var, Cuts=True)  #HT_all
    Sampler = SampleHandler.SampleHandler(ListSamples)
    Sampler.norm = False  #Y axis norm to one
    Sampler.valSize = 0.2
    Sampler.Split = 'EO'
    Sampler.Scale = None  #X axis scaling for NN
    Sampler.SequenceLength = 0
    Sampler.Plots = False
    DataSet = Sampler.GetANNInput(verbose=0)
    train, test = DataSet.GetInput("Even")
    vali = DataSet.vali
    PlotService.VarHist(DataSet,
                        'NLO',
                        './plots/',
                        'test',
                        V,
                        r"H_{T} [GeV]",
                        500,
                        2200,
                        30,
                        Norm=True)
    os.system("mv plots/" + V + ".png plots/" + V + "_wo.png")
    OutPreSig = OutPre[:, 0]
    cut, senSig = FindCut(OutPreSig, test.OutTrue, test.Weights)
    print(cut, senSig)
    Events = test.Events[OutPreSig > cut]
    Weights = test.Weights[OutPreSig > cut]
    OutTrue = test.OutTrue[OutPreSig > cut]
    MultiClass = test.MultiClass[OutPreSig > cut]
    NewSample = DIClasses.DISample(Events, Weights, OutTrue, MultiClass,
                                   vali.LVariables, vali.Names)
    PlotService.VarHist(NewSample,
                        'NLO',
                        './plots/',
                        'test',
                        V,
                        r"H_{T} [GeV]",
                        500,
                        2200,
                        30,
                        Norm=True)  #H_{\text{T}}^{\text{all}} [GeV]
Exemplo n.º 5
0
 def EvaluateFNN(self):
     LOutPreOther = []
     for Name in self.ModelNames:
         if ("BDT" in Name):  #Import the BDT Scores as comperison
             OutPreOther, OutPreSame = self.GetOutPreFromFile(Name)
         else:
             OutPreOther, OutPreSame = self.GetOutPreFromRoc(Name)
         PreLabelsOther, PreLabelsSame = self.PredictClasses(
             OutPreOther, OutPreSame)
         self.MakeConfusionMatrix(Name, PreLabelsOther, PreLabelsSame)
         PlotService.Score("./plots/", OutPreOther[:, 0], OutPreSame[:, 0],
                           self.DataSet, Name)
         PlotService.MultiScore("./plots/", OutPreOther[:, 0],
                                OutPreSame[:, 0], self.DataSet, Name,
                                0)  #Score for Sig
         LOutPreOther.append(OutPreOther[:, 0])
     PlotService.RocCurve("./plots/", LOutPreOther, self.DataSet,
                          self.ModelNames)
Exemplo n.º 6
0
    def GetANNInput(self, verbose=1):

        if (self.mode[:4] == 'Slow' or self.mode[:4] == 'Save'):
            self.verbose = verbose
            if (self.verbose == 1):
                Utils.stdinfo("Setting up input vectors")

            #Import Variables as an numoy array
            for DISetup in self.ListAnaSetup:
                if (self.verbose == 1):
                    print("Processing Sample: " + DISetup.Name)
                ListOfVariables = DISetup.LVars[:]
                if (self.mode[:4] == 'Fast' and DISetup.Name != 'NLO'):
                    ListOfVariables.append('Weight')
                else:
                    ListOfVariables.extend(DISetup.WeightList)
                Arr = self.GetArray(ListOfVariables, DISetup)
                np.random.shuffle(Arr)  #ensure randomize of event order
                DISetup.Samples = self.MakeSplit(Arr, DISetup)  #Split samples
                if (self.verbose == 1):
                    self.Info(DISetup)

            #Combine the different sets into a DataSet
            if (self.verbose == 1):
                Utils.stdinfo("finalising input Preparation")
            ListSamples = [DISetup.Samples for DISetup in self.ListAnaSetup]
            train = self.Finalise("train", ListSamples)
            test = self.Finalise("test", ListSamples)
            vali = self.Finalise("validation", ListSamples)
            DataSet = DIDataSet(train, test, vali)

        # Save the numpy arrays to load them faster later
        if (self.mode[:4] == 'Save'):
            if (self.verbose == 1):
                Utils.stdinfo("Saving data for Fast mode")
            self.SaveNpy('TrainSet' + self.mode[4:], train)
            self.SaveNpy('TestSet' + self.mode[4:], test)
            self.SaveNpy('ValiSet' + self.mode[4:], vali)

        # If stored as numpy arrays load the arrays
        elif (self.mode[:4] == 'Fast'):
            train = self.GetSampleNpy('TrainSet' + self.mode[4:])
            test = self.GetSampleNpy('TestSet' + self.mode[4:])
            vali = self.GetSampleNpy('ValiSet' + self.mode[4:])
            DataSet = DIDataSet(train, test, vali)

        #Make Plots of the Variables
        if (self.Plots != False):
            PlotService.VarHists(DataSet,
                                 key='All',
                                 Norm=self.NormFlag,
                                 Sig=self.Plots)

        return DataSet
Exemplo n.º 7
0
def Fit(OutPre):
    Var = ['met_met']
    stdinfo("Getting the variable from the root file")
    ListSamples = Init(Var,Cuts=True)     #HT_all
    Sampler = SampleHandler.SampleHandler(ListSamples)
    Sampler.norm    = False                                     #Y axis norm to one
    Sampler.valSize = 0.2
    Sampler.Split   = 'EO'
    Sampler.Scale   = 'None'                                    #X axis scaling for NN
    Sampler.SequenceLength  = 0
    Sampler.Plots = False
    DataSet       = Sampler.GetANNInput(verbose=0)
    train, test = DataSet.GetInput("Even")
    #VarHist(Sampler.ListAnaSetup,'./plots/','test', "HT_all", r"H_{\text{T}}^{\text{all}} [GeV]",500,2000,30,Norm=False)            
    cut  = 0.31                                                                     #TODO: Implement best cut search    
    PlotService.SBVar('./plots/',Var[0],test, r"H_{\text{T}}^{\text{all}} [GeV]",30,0,500,tag='_after_'+str(cut)+'_cut',Norm=False)
    Events = test.Events[OutPre > cut]
    Weights = test.Weights[OutPre > cut]
    OutTrue = test.OutTrue[OutPre > cut]
    NewSample = DISample(Events,Weights,None,OutTrue,None)
    PlotService.SBVar('./plots/',Var[0],NewSample, r"H_{\text{T}}^{\text{all}} [GeV]",30,0,500,tag='No_cut',Norm=False)
    assert 0 == 1   #TODO:Check plot
    def Main(self):
        #importing the Variable to plot
        Samples    = 'nomLoose'
        Utils.stdinfo("Getting the variable from the root file")
        ListSamples = DIClasses.Init([self.Var],Samples,Cuts=True)     #HT_all
        Sampler = SampleHandler.SampleHandler(ListSamples)
        Sampler.norm    = False                                     #Y axis norm to one
        Sampler.valSize = 0.2
        Sampler.Split   = 'EO'
        Sampler.Scale   = None                                      #X axis scaling for NN
        Sampler.SequenceLength  = 0
        Sampler.Plots = False
        DataSet       = Sampler.GetANNInput(verbose=0)

        for Name in self.ModelNames:
            self.Name = Name
            # Plotting the variable with any NN Score cuts
            PlotService.VarHist(DataSet,'NLO','./plots/','All', self.Var, r"H_{T} [GeV]",500,2200,30,Norm=True)
            if("Even" in Name):
                os.system("mv plots/"+self.Var+".png plots/"+self.Var+"_wo_Even.png")
            elif("Odd" in Name):
                os.system("mv plots/"+self.Var+".png plots/"+self.Var+"_wo_Odd.png")

            #Optimizing a cut based on S/sqrt(S+B) and apllying it to the variable
            OutPre = MakePrediction(DataSet)
            cut, senSig = FindCut(OutPre,DataSet)
            print(cut, senSig)         
            test = ApllyCuts(test,OutPre[1],cut)
            train = ApllyCuts(train,OutPre[0],cut)
            vali = ApllyCuts(vali,OutPre[2],cut)
            NewDataSet = DIClasses.DIDataSet(test,train,vali)
            PlotService.VarHist(NewDataSet,'NLO','./plots/','All', self.Var, r"H_{T} [GeV]",500,2200,30,Norm=True)  #H_{\text{T}}^{\text{all}} [GeV]
            if("Even" in Name):
                os.system("mv plots/"+self.Var+".png plots/"+self.Var+"_Even.png")
            elif("Odd" in Name):
                os.system("mv plots/"+self.Var+".png plots/"+self.Var+"_Odd.png")
def CrossCheck(dataloader):

    DataSet = dataloader.GetDataSetInfo().GetDataSet()
    EventCollection = DataSet.GetEventCollection()
    BkgW, SigW = np.zeros([]), np.zeros([])
    Bkg, Sig = np.zeros([]), np.zeros([])
    for Event in EventCollection:
        if (Event.GetClass() == 1):
            Bkg = np.append(Bkg, Event.GetValue(1))
            BkgW = np.append(BkgW, Event.GetWeight())
        elif (Event.GetClass() == 0):
            Sig = np.append(Sig, Event.GetValue(1))
            SigW = np.append(SigW, Event.GetWeight())
    PlotService.VarCrossCheck(Sig, Bkg, SigW, BkgW, 'njets', -6, 4, 10)

    return
Exemplo n.º 10
0
def PreCutScore(OutPreOther, OutPreSame, DataSet, Name):
    """ Plots a Score distribution after cutting on the signal Score distribution """
    cut = 0.8
    ScoreNum = 11
    train, test = DataSet.GetInput("Even")
    SigScoreOther = OutPreOther[:, 0]  #Choosing the signal Score
    SigScoreSame = OutPreSame[:, 0]
    SecScoreOther = (OutPreOther[:, ScoreNum])[SigScoreOther > 0.8]
    SecScoreSame = (OutPreSame[:, ScoreNum])[SigScoreSame > 0.8]
    test = DIClasses.DISample(None, test.Weights[SigScoreOther > 0.8],
                              test.OutTrue[SigScoreOther > 0.8],
                              test.MultiClass[SigScoreOther > 0.8])
    train = DIClasses.DISample(None, train.Weights[SigScoreSame > 0.8],
                               train.OutTrue[SigScoreSame > 0.8],
                               train.MultiClass[SigScoreSame > 0.8])
    DataSet = DIClasses.DIDataSet(train, test, None, None)

    PlotService.MultiScore("./plots/", SecScoreOther, SecScoreSame, DataSet,
                           Name, ScoreNum)
Exemplo n.º 11
0
    def PhyNNCompare(self, layer, LCompareVar):
        """
        Comparesion of the neuron output in a given layer to variables that are build by using physics intuition
        layer:              Which Layer should be used for the comparision?
        LCompareVar:        List of Variables to which the neuron Output is compared
        """
        ListSamples = DIClasses.Init(LCompareVar, Cuts=True)
        Sampler = SampleHandler.SampleHandler(ListSamples)
        Sampler.norm = False
        Sampler.SequenceLength = 0
        Sampler.Plots = False
        CompareData = Sampler.GetANNInput(verbose=0)
        CompareTrain, CompareTest = CompareData.GetInput("Even")
        train, test = self.DataSet.GetInput("Even")

        input1 = self.Model.input  # input placeholder
        output1 = [l.output for l in self.Model.layers]  # all layer outputs
        fun = K.function([input1, K.learning_phase()],
                         output1)  # evaluation function
        LayerOutput = fun([train.Events, 1.])
        Layer = LayerOutput[layer - 4]
        for i in range(Layer.shape[1]):
            for j in range(CompareTrain.Events.shape[1]):
                NeuronOutput = DIClasses.DISample(
                    Utils.Transform(Layer[:, i],
                                    'MinMax'), CompareTrain.Weights, None,
                    CompareTrain.OutTrue, None, None)
                CompareVar = DIClasses.DISample(
                    Utils.Transform(CompareTrain.Events[:, j],
                                    'MinMax'), CompareTrain.Weights, None,
                    CompareTrain.OutTrue, None, None)
                #PlotService.SigBkgHist(NeuronOutput,'Neuron ('+str(i)+') [a.u.]',40,0,1,tag='_Neuron_'+str(i))
                #PlotService.SigBkgHist(CompareVar, LCompareVar[j], 40,0,1,tag='LCompareVar'+str(j))
                Hist2D = PlotService.SigBkg2D(CompareVar, NeuronOutput,
                                              'Neuron (' + str(i) + ') [a.u.]',
                                              LCompareVar[j], 30, 30, 0, 1, 0,
                                              1)
                Utils.stdinfo(
                    "The mutual information of Neuron {0} and {1} is : {2}".
                    format(i, LCompareVar[j], self.GetNormedMi(Hist2D)))
Exemplo n.º 12
0
def VarHists(DataSet, key="train", Norm=False, Sig="LO"):

    path = "./plots/Variables/"
    bins = 30

    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "leading_jet_pT",
                        r"p_{T}(j)^{\text{leading}} [GeV]",
                        0,
                        800,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "lep_0_pt",
                        r"p_{T}(\ell)^{\text{leading}} [GeV]",
                        0,
                        500,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "nJets",
                        "Jet multiplicity",
                        4,
                        14,
                        10,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "met_met",
                        r" E_{T}^{\text{miss}} [GeV]",
                        0,
                        500,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "deltaR_ll_min",
                        r"\Delta R(\ell,\ell)_{min}",
                        0,
                        5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "deltaR_ll_max",
                        r"\Delta R(\ell,\ell)_{max}",
                        0,
                        5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "deltaR_ll_sum",
                        r"\sum \Delta R(\ell,\ell)",
                        0,
                        10,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "deltaR_bb_min",
                        r"\Delta R(b,b)_{min}",
                        0,
                        5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "jet_sum_mv2c10_Continuous",
                        r"\sum w_{Mv2c10}",
                        10,
                        25,
                        15,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'deltaPhi_l0j0',
                        r'\Delta \Phi (l_{0}j_{0})',
                        0,
                        3.141,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'deltaR_bj_min',
                        r'\Delta R(b,j)_{min}',
                        0,
                        2.5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'deltaR_lb_max',
                        r'\Delta R(\ell,b)_{max}',
                        1,
                        5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'deltaR_lb_min',
                        r'\Delta R(\ell,b)_{min}',
                        0,
                        3,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'deltaR_lj_min',
                        r'\Delta R(\ell,j)_{min}',
                        0,
                        2,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'HT_jets_noleadjet',
                        'H_{T}^{no leading jet} [GeV]',
                        100,
                        1200,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'jet_1_pt',
                        'jet1 p_{T} [GeV]',
                        0,
                        500,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'jet_mass_dividedby_pt_max',
                        'm_{jet}/max(jet p_{T})',
                        0.1,
                        0.3,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'leading_bjet_pT',
                        'Leading b-jet p_{T} [GeV]',
                        0,
                        500,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'lep_1_pt',
                        'lep1 p_{T} [GeV]',
                        20,
                        200,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'lep_2_pt',
                        'lep2 p_{T} [GeV]',
                        0,
                        150,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'lep_0_phi',
                        r'\phi (\ell)^{\text{leading}}',
                        0,
                        3.2,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'lowest_jet_pT',
                        'lowest Jet p_{T} [GeV]',
                        0,
                        80,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'met_phi',
                        r'\phi^{\text{miss}}',
                        -3.5,
                        3.5,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'nleps',
                        r'Number of leptons',
                        0,
                        10,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'lep_0_eta',
                        r'\eta_{lep,0}',
                        -2.7,
                        2.7,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'el_eta[0]',
                        r'el eta',
                        -3.141,
                        3.141,
                        bins,
                        Norm=Norm)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        "jet_5_pt",
                        r"lep5 p_{T} [GeV]",
                        20,
                        100,
                        bins,
                        Norm=Norm)
    # PlotService.VarHist(DataSet, Sig,path,key, "Evt_Channel", r"Event Channel",1,7,7,Norm=Norm)

    #Jet
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'jet_pt',
                        r'Seq_pt_{j}^{0} [GeV]',
                        0,
                        1000,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{1} [GeV]', 0, 650, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{2} [GeV]', 0, 600, bins, Norm=Norm, pos=2)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{3} [GeV]', 0, 600, bins, Norm=Norm, pos=3)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{4} [GeV]', 0, 600, bins, Norm=Norm, pos=4)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{5} [GeV]', 0, 600, bins, Norm=Norm, pos=5)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{6} [GeV]', 0, 600, bins, Norm=Norm, pos=6)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{7} [GeV]', 0, 150, bins, Norm=Norm, pos=7)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_pt', r'Seq_pt_{j}^{8} [GeV]', 0, 150, bins, Norm=Norm, pos=8)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'jet_eta',
                        r'Seq_\eta_{j}^{0}',
                        -2.5,
                        2.5,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{1}', -2.5, 2.5, bins, Norm=Norm,pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{2}', -2.5, 2.5, bins, Norm=Norm,pos=2)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{3}', -2.5, 2.5, bins, Norm=Norm,pos=3)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{4}', -2.5, 2.5, bins, Norm=Norm,pos=4)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{5}', -2.5, 2.5, bins, Norm=Norm, pos=5)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{6}', -2.5, 2.5, bins, Norm=Norm, pos=6)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{7}', -2.5, 2.5, bins, Norm=Norm, pos=7)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_eta', r'Seq_\eta_{j}^{8}', -2.5, 2.5, bins, Norm=Norm, pos=8)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'jet_phi',
                        r'Seq_\phi_{j}^{0}',
                        -3.14,
                        3.14,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{1}', -3.14, 3.14, bins, Norm=Norm,pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{2}', -3.14, 3.14, bins, Norm=Norm,pos=2)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{3}', -3.14, 3.14, bins, Norm=Norm,pos=3)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{4}', -3.14, 3.14, bins, Norm=Norm,pos=4)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{5}', -3.14, 3.14, bins, Norm=Norm, pos=5)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{6}', -3.14, 3.14, bins, Norm=Norm, pos=6)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{7}', -3.14, 3.14, bins, Norm=Norm, pos=7)
    # PlotService.VarHist(DataSet, Sig,path,key, 'jet_phi', r'Seq_\phi_{j}^{8}', -3.14, 3.14, bins, Norm=Norm, pos=8)
    #electron
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'el_pt',
                        r'Seq_pt_{el}^{0} [GeV]',
                        20,
                        400,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_pt', r'Seq_pt_{el}^{1} [GeV]', 20, 400, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_pt', r'Seq_pt_{el}^{2} [GeV]', 20, 400, bins, Norm=Norm, pos=2)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'el_eta',
                        r'Seq_\eta_{el}^{0}',
                        -2.5,
                        2.5,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_eta', r'Seq_\eta_{el}^{1}', -2.5, 2.5, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_eta', r'Seq_\eta_{el}^{2}', -2.5, 2.5, bins, Norm=Norm, pos=2)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'el_phi',
                        r'Seq_\phi_{el}^{0}',
                        -3.14,
                        3.14,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_phi', r'Seq_\phi_{el}^{1}', -3.14, 3.14, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'el_phi', r'Seq_\phi_{el}^{2}', -3.14, 3.14, bins, Norm=Norm, pos=2)
    #muon
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'mu_pt',
                        r'Seq_pt_{\mu}^{0} [GeV]',
                        0,
                        400,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'mu_pt', r'Seq_pt_{\mu}^{1} [GeV]', 0, 350, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'mu_pt', r'Seq_pt_{\mu}^{2} [GeV]', 0, 350, bins, Norm=Norm, pos=2)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'mu_eta',
                        r'Seq_\eta_{\mu}^{0}',
                        -2.5,
                        2.5,
                        bins,
                        Norm=Norm,
                        pos=0)
    # PlotService.VarHist(DataSet, Sig,path,key, 'mu_eta', r'Seq_\eta_{\mu}^{1}', -2.5, 2.5, bins, Norm=Norm, pos=1)
    # PlotService.VarHist(DataSet, Sig,path,key, 'mu_eta', r'Seq_\eta_{\mu}^{2}', -2.5, 2.5, bins, Norm=Norm, pos=2)
    PlotService.VarHist(DataSet,
                        Sig,
                        path,
                        key,
                        'mu_phi',
                        r'Seq_\phi_{\mu}`^{0}',
                        -3.14,
                        3.14,
                        bins,
                        Norm=Norm,
                        pos=0)
Exemplo n.º 13
0
    def GetANNInput(self):

        # SLOW or SAVE Modes  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
        if self.mode[:4] == 'Slow' or self.mode[:4] == 'Save':

            Utils.stdinfo("\nSetting up input vectors!\n")

            print(
                "------------------------------------------------------------------------------------------------"
            )
            print(
                "   Sample         Total          Training       Testing        Validation     Yield             "
            )
            print(
                "================================================================================================"
            )

            # Import Variables as a NumPy array
            for DISetup in self.ListAnaSetup:

                print(" " * 3 + DISetup.Name.ljust(15, " "), end="")

                ListOfVariables = DISetup.LVars[:]
                ListOfVariables.extend(DISetup.WeightList)

                Arr = self.GetArray(ListOfVariables, DISetup)  # Defined below
                np.random.shuffle(
                    Arr
                )  # Ensures randomization of event order. Seed fixed in FNN.py[17]

                DISetup.Samples = self.MakeSplit(Arr, DISetup)  # Split samples

                self.Info(
                    DISetup
                )  # Defined below: Displays the information about the sample sizes

            # Combine the different sets into a DataSet
            Utils.stdinfo("\nFinalising input preparation!\n")

            ListSamples = [DISetup.Samples for DISetup in self.ListAnaSetup]

            train = self.Finalise("train", ListSamples)  # Defined below
            test = self.Finalise("test", ListSamples)
            vali = self.Finalise("validation", ListSamples)

            DataSet = DIDataSet(train, test, vali)

            # Save the NumPy arrays to load them faster later
            if self.mode[:4] == 'Save':
                Utils.stdinfo("Saving data for Fast mode")
                self.SaveNpy('TrainSet' + self.mode[4:], train)
                self.SaveNpy('TestSet' + self.mode[4:], test)
                self.SaveNpy('ValiSet' + self.mode[4:], vali)

        # FAST Mode ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ #
        elif self.mode[:4] == 'Fast':

            train = self.GetSampleNpy('TrainSet' + self.mode[4:])
            test = self.GetSampleNpy('TestSet' + self.mode[4:])
            vali = self.GetSampleNpy('ValiSet' + self.mode[4:])

            DataSet = DIDataSet(train, test, vali)

        # Make Plots of the Variables
        if self.Plots != False:
            PlotService.VarHists(DataSet,
                                 key='All',
                                 Norm=self.NormFlag,
                                 Sig=self.Plots)

        return DataSet