lumiF_noHIMP = 0.57
    lumiG = 7.54
    lumiH = 8.61
    lumi = lumiB + lumiC + lumiD + lumiE + lumiF + lumiG + lumiH  # luminosity

    lumi_preVFP = 5.79 + 2.57 + 4.25 + 4.01 + 2.53
    lumi_postVFP = 0.57 + 7.54 + 8.61
    lumi_2017 = 41.48
    lumi_2018 = 59.83

    filename = args.dat

    ############# Tree creation
    if not args.condor:
        treeSI_2016 = Sample.Tree(fileName=helper.selectSamples(
            WORKPATH + 'dat/signals_2016UL.dat', Signals_2016, 'SI'),
                                  name='SI',
                                  isdata=0)
        treeSI_2017 = Sample.Tree(fileName=helper.selectSamples(
            WORKPATH + 'dat/signals_2017UL.dat', Signals_2017, 'SI'),
                                  name='SI',
                                  isdata=0)
        treeSI_2018 = Sample.Tree(fileName=helper.selectSamples(
            WORKPATH + 'dat/signals_2018UL.dat', Signals_2018, 'SI'),
                                  name='SI',
                                  isdata=0)
    if doDATA:
        treeDATA2016 = Sample.Tree(fileName=helper.selectSamples(
            WORKPATH + filename, DoubleMuon2016 + DoubleEG2016, 'DATA'),
                                   name='DATA',
                                   isdata=1)
        treeDATA2017 = Sample.Tree(fileName=helper.selectSamples(
Example #2
0
    Signals2016.append('HSS_125_50_100_2016')
    Signals2016.append('HSS_125_50_1000_2016')
    #Signals2016.append('HSS_125_50_10000_2016')
    Signals2016.append('HSS_400_50_1_2016')
    Signals2016.append('HSS_400_50_10_2016')
    Signals2016.append('HSS_400_50_100_2016')
    Signals2016.append('HSS_400_50_1000_2016')
    #Signals2016.append('HSS_400_50_10000_2016')
    Signals2016.append('HSS_1000_350_1_2016')
    Signals2016.append('HSS_1000_350_10_2016')
    Signals2016.append('HSS_1000_350_100_2016')
    Signals2016.append('HSS_1000_350_1000_2016')
    #Signals2016.append('HSS_1000_350_10000_2016')

    treeSI = Sample.Tree(fileName=helper.selectSamples(
        GALAPAGOPATH + 'signals_2016.dat', Signals2016, 'MC'),
                         name='2016',
                         isdata=0)

    ###################################
    ####   Loop over tree events   ####
    ###################################
    cm = CutManager.CutManager()

    for b in treeSI.blocks:
        for s in b.samples:
            histograms['hist_E_relTrkIso_' + s.name] = r.TH1F(
                "hist_E_relTrkIso_" + s.name, "", 50, 0, 1)
            histograms['hist_E_relTrkIso_log_' + s.name] = r.TH1F(
                "hist_E_relTrkIso_log_" + s.name, "",
                len(bin_iso_log) - 1, bin_iso_log)
            histograms['hist_E_relPFIso_' + s.name] = r.TH1F(
Example #3
0
    ############# Signal definition
    Signals = []
    Signals.append('HXX_1000_350_350mm')
    Signals.append('HXX_1000_350_35mm')
    Signals.append('HXX_1000_150_100mm')
    Signals.append('HXX_1000_150_10mm')
    Signals.append('HXX_400_150_400mm')
    Signals.append('HXX_400_50_400mm')
    Signals.append('HXX_400_50_40mm')
    Signals.append('HXX_400_50_4mm')

    ############# Luminosity definition

    filename = 'dat/Samples_cern_fillingv2.dat'
    treeSI = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       Signals, 'MC'),
                         name='SI',
                         isdata=0)

    makeCutStability('SI_MMdPhiStability_2016',
                     'hMM_cutEfficiency',
                     12,
                     False,
                     treeSI,
                     WORKPATH + opts.input,
                     outtag='LLefficiencies',
                     LLlabel='MM')
    makeCutStability('SI_EEdPhiStability_2016',
                     'hEE_cutEfficiency',
                     11,
                     False,
                     treeSI,
    ############# Background definition
    Backgrounds = []
    Backgrounds.append('WJetsToLNu')
    Backgrounds.append('WW')
    Backgrounds.append('WZ')
    Backgrounds.append('ZZ')
    Backgrounds.append('DYJetsToLL_M-50')
    Backgrounds.append('DYJetsToLL_M-10to50')
    Backgrounds.append('QCD_Pt-30to40')
    Backgrounds.append('QCD_Pt-40toInf')

    lumi = 36.773

    ############# Tree creation
    treeMC = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/MC.dat', Backgrounds, 'MC'), 'MC',
        0, WORKPATH + opts.inputFile)

    #makeBackgroundValidation(lumi, treeMC, 'EEsel_leadingPt', 'EEsel_leadingPt', 'Leading p_{T} (GeV/c)', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_subleadingPt', 'EEsel_subleadingPt', 'Subleading p_{T} (GeV/c)', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_invMass', 'EEsel_invMass', 'Mass (GeV/c^{2})', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_Chi2', 'EEsel_Chi2', 'Vertex #Chi^{2}', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_dPhi', 'EEsel_dPhi', 'Collinearity |#Delta#Phi|', 1, 'EE')
    makeCumulativeValidation(lumi, treeMC, 'EEsel_minIxy', 'EEsel_minIxy',
                             '|d_{0}|/#sigma_{d}', 1, 'EE')

    #makeBackgroundValidation(lumi, treeMC, 'MMsel_leadingPt', 'MMsel_leadingPt', 'Leading p_{T} (GeV/c)', 1, 'MM')
    #makeBackgroundValidation(lumi, treeMC, 'MMsel_subleadingPt', 'MMsel_subleadingPt', 'Subleading p_{T} (GeV/c)', 1, 'MM')
    #makeBackgroundValidation(lumi, treeMC, 'MMsel_invMass', 'MMsel_invMass', 'Mass (GeV/c^{2})', 1, 'MM')
    #makeBackgroundValidation(lumi, treeMC, 'MMsel_Chi2', 'MMsel_Chi2', 'Vertex #Chi^{2}', 1, 'MM')
    #makeBackgroundValidation(lumi, treeMC, 'MMsel_dPhi', 'MMsel_dPhi', 'Collinearity |#Delta#Phi|', 1, 'MM')
Example #5
0
    DoubleMuon2016 = []
    DoubleMuon2016.append('DoubleMuon_Run2016B_HIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016C_HIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016D_HIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016E_HIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016F_HIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016F_noHIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016G_noHIPM')
    DoubleMuon2016.append('DoubleMuon_Run2016H_noHIPM')

    ########### .dat definition
    filename = opts.dat

    ########### Data Tree's declaration
    treeMuonDATA = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleMuon2016, 'DATA'),
                               name='DATA',
                               isdata=1)

    ###########################################
    ########## Read recipe
    #####

    recipe = DatacardManager.Recipe(opts.recipe)
    datacards = recipe.dcs

    ###########################################
    ########## Loop over datacards
    #####

    for datacard_name in datacards.keys():
    #### ---- Histograms
    #### -----------------

    bin_iso_log = np.logspace(-3, 2)
    hist_E_relTrkIso     = r.TH1F("hist_E_relTrkIso", "", 50, 0, 1)
    hist_E_relTrkIso_log = r.TH1F("hist_E_relTrkIso_log", "", len(bin_iso_log) -1, bin_iso_log)
    hist_E_relPFIso      = r.TH1F("hist_E_relPFIso", "", 50, 0, 1)
    hist_E_relPFIso_log  = r.TH1F("hist_E_relPFIso_log", "", len(bin_iso_log) -1, bin_iso_log)
    hist_M_relPFIso      = r.TH1F("hist_M_relPFIso", "", 50, 0, 1)
    hist_M_relPFIso_log  = r.TH1F("hist_M_relPFIso_log", "", len(bin_iso_log) -1, bin_iso_log)

    #########################
    ####   Load sample   ####
    #########################

    treeBKG = Sample.Tree( fileName = helper.selectSamples(GALAPAGOPATH + 'dat/Samples_cern_UltraLegacy.dat', ['WW_postVFP', 'WZ_postVFP'], 'MC'), name = '2016', isdata = 0 )


    ###################################
    ####   Loop over tree events   ####
    ###################################
    cm = CutManager.CutManager()

    for b in treeBKG.blocks:
        for s in b.samples:
            for t in s.ttrees:

                print('New tree with:', t.GetEntries())

                for e,ev in enumerate(t):
    Signals2017.append('HSS_400_50_10000_2017')
    Signals2018 = []
    Signals2018.append('HSS_400_50_1_2018')
    Signals2018.append('HSS_400_50_10_2018')
    Signals2018.append('HSS_400_50_100_2018')
    Signals2018.append('HSS_400_50_1000_2018')
    Signals2018.append('HSS_400_50_10000_2018')

    ############# Luminosity definition
    lumi2016 = 35.9  # fb-1
    lumi2017 = 41.5  # fb-1
    lumi2018 = 59.7  # fb-1

    ############# Galapago Tree definitions
    treeSI_2016 = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'signals_2016.dat', Signals2016, 'SI'),
                              name='SI',
                              isdata=0)
    treeSI_2017 = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'signals_2017.dat', Signals2017, 'SI'),
                              name='SI',
                              isdata=0)
    treeSI_2018 = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'signals_2018.dat', Signals2018, 'SI'),
                              name='SI',
                              isdata=0)

    treeDATA_EG2016 = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleEG2016, 'DATA'),
                                  name='DATA',
                                  isdata=1)
    treeDATA_EG2017 = Sample.Tree(fileName=helper.selectSamples(
Example #8
0
                  dest='LUMI',
                  help='Luminosity value')
parser.add_option('-p',
                  '--option',
                  action='store',
                  type=str,
                  dest='OPTION',
                  help='Option')

(opts, args) = parser.parse_args()

############ datFile definition
datFile = opts.DATFILE

############ Initialize the output root file
outputPath = opts.OUTPATH if opts.OUTPATH[-1] == '/' else opts.OUTPATH + '/'
if not os.path.exists(outputPath): os.makedirs(outputPath)  # ensure the path
outputName = outputPath + 'fill_' + opts.SAMPLE + '.root'
output = r.TFile(outputName, "RECREATE")
output.Close()

sampleList = []
sampleList.append(opts.SAMPLE)

############ Tree creation
tree = Sample.Tree(helper.selectSamples(opts.DATFILE, sampleList, opts.OPTION),
                   opts.OPTION, 0, outputName)

############ Tree loop
tree.Loop(opts.LUMI, False, False)
Example #9
0
    DoubleMuon_list = []
    DoubleMuon_list.append(DoubleMuonB)
    DoubleMuon_list.append(DoubleMuonC)
    DoubleMuon_list.append(DoubleMuonD)
    DoubleMuon_list.append(DoubleMuonE)
    DoubleMuon_list.append(DoubleMuonF)
    DoubleMuon_list.append(DoubleMuonG)
    DoubleMuon_list.append(DoubleMuonH)

    ########### .dat definition
    filename = 'dat/Samples_cern_fillingv2.dat'

    ########### Data Tree's declaration
    treeEGDATA = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleEG_list, 'DATA'),
                             name='DATA',
                             isdata=1)
    treeMuonDATA = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleMuon_list, 'DATA'),
                               name='DATA',
                               isdata=1)

    ###########################################
    ########## Muon channel datacards
    #####

    #MMchannel_nMMe1 = DatacardManager.Channel('MMe1', 'trackIxy', 6.0, -99)
    MMchannel_nMMe1_I = DatacardManager.Channel('MMe1_I', 'trackIxy', 6.0,
                                                10.0)
    MMchannel_nMMe1_II = DatacardManager.Channel('MMe1_II', 'trackIxy', 11.0,
                                                 15.0)
    lumiF = 3.10
    lumiG = 7.54
    lumiH = 8.61
    lumi_total = lumiB + lumiC + lumiD + lumiE + lumiF + lumiG + lumiH  # luminosity
    lumi_list = [lumiB, lumiC, lumiD, lumiE, lumiF, lumiG, lumiH]

    filename = 'dat/Samples_cern_fillingv2.dat'

    letter = ['B', 'C', 'D', 'E', 'F', 'G', 'H']

    #
    # -- QCD Correlation
    #

    treeEG = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       DoubleEG_list, 'DATA'),
                         name='DATA',
                         isdata=1)
    treeMuon = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleMuon_list, 'DATA'),
                           name='DATA',
                           isdata=1)
    makeSymmetryTest(lumi_total, 'hEESS0_dPhi', 0, treeEG,
                     WORKPATH + opts.input,
                     'DoubleEG_Run2016[B-H] (SS0 Region)',
                     'DATAEG_hEESS0_dPhi_corr', 1)
    makeSymmetryTest2(lumi_total, 'hEESS0_dPhi', 0, treeEG,
                      WORKPATH + opts.input,
                      'DoubleEG_Run2016[B-H] (SS0 Region)',
                      'DATAEG_hEESS0_dPhi_test', 1)
    makeSymmetryTest2(lumi_total,
                      'hEEOS0disp_dPhi',
    Signals_400_50_2018.append('HSS_400_50_1_2018')
    Signals_400_50_2018.append('HSS_400_50_10_2018')
    Signals_400_50_2018.append('HSS_400_50_100_2018')
    Signals_400_50_2018.append('HSS_400_50_1000_2018')
    Signals_400_50_2018.append('HSS_400_50_10000_2018')

    Signals_1000_350_2018 = []
    Signals_1000_350_2018.append('HSS_1000_350_1_2018')
    Signals_1000_350_2018.append('HSS_1000_350_10_2018')
    Signals_1000_350_2018.append('HSS_1000_350_100_2018')
    Signals_1000_350_2018.append('HSS_1000_350_1000_2018')
    Signals_1000_350_2018.append('HSS_1000_350_10000_2018')

    filename = 'dat/Samples_cern_UltraLegacy.dat'
    #treeMC = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, Backgrounds, 'MC'), name = 'MC', isdata = 0 )
    treeSI_400_50_2016 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + 'signals_2016.dat', Signals_400_50_2016, 'MC'), name = 'SI', isdata = 0 )
    treeSI_400_50_2017 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + 'signals_2017.dat', Signals_400_50_2017, 'MC'), name = 'SI', isdata = 0 )
    treeSI_400_50_2018 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + 'signals_2018.dat', Signals_400_50_2018, 'MC'), name = 'SI', isdata = 0 )
    treeSI_1000_350_2018 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + 'signals_2018.dat', Signals_1000_350_2018, 'MC'), name = 'SI', isdata = 0 )

    MMlabels = []
    MMlabels.append('Muon trigger')
    MMlabels.append('Good PV')
    MMlabels.append('Have MM passing ID')
    MMlabels.append('p_{T} > 25 GeV')
    MMlabels.append('|#eta| < 2')
    MMlabels.append('#Delta R > 0.2')
    MMlabels.append('m_{#mu#mu} > 15 GeV')
    MMlabels.append('Rel. PFIso < 0.2')
    MMlabels.append('Vertex #chi^{2}/ndof < 10')
    MMlabels.append('Cosmic muon rejection')
    hBKG_B_rebin = hBKG_B.Rebin(len(newbin)-1, 'hBKG_B_rebin', newbin)
    makeClosureTestMC(lumi = '', name = 'VV_EE_2018', hBKG_A = hBKG_A_rebin, hBKG_B = hBKG_B_rebin, ylog = True, tree = treeVV_2018, inputdir = opts.input, labelB = 'Control Region: |#Delta#Phi|_{ee} > #pi/2', labelA = 'Signal Region: |#Delta#Phi|_{ee} < #pi/2', xlabel = '|d_{xy}|/#sigma_{d}', outtag = 'EEChannelV2', yshift = 0.0, LLlabel = 'EE', DATAlabel = '2018 UL', extralabel = 'WW, WZ, ZZ (Baseline selection)')

    hBKG_A = treeVV_2018.getLoopTH1F(opts.input, 'hMMSR_trackIxy')
    hBKG_B = treeVV_2018.getLoopTH1F(opts.input, 'hMMBCR_trackIxy')
    newbin = np.linspace(0., 25., 26)
    hBKG_A_rebin = hBKG_A.Rebin(len(newbin)-1, 'hBKG_A_rebin', newbin)
    hBKG_B_rebin = hBKG_B.Rebin(len(newbin)-1, 'hBKG_B_rebin', newbin)
    makeClosureTestMC(lumi = '', name = 'VV_MM_2018', hBKG_A = hBKG_A_rebin, hBKG_B = hBKG_B_rebin, ylog = True, tree = treeVV_2018, inputdir = opts.input, labelB = 'Control Region: |#Delta#Phi|_{#mu#mu} > #pi/2', labelA = 'Signal Region: |#Delta#Phi|_{ee} < #pi/2', xlabel = '|d_{xy}|/#sigma_{d}', outtag = 'MMChannelV2', yshift = 0.0, LLlabel = 'MM', DATAlabel = '2018 UL', extralabel = 'WW, WZ, ZZ (Baseline selection)', rmax = 3.0)

    """

    #
    # -- QCD and Wjets Correlation
    #
    tree_EE2016_HIPM = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG2016_HIPM, 'MC'), name = 'DATA', isdata = 1 )
    tree_MM2016_HIPM = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleMuon2016_HIPM, 'MC'), name = 'DATA', isdata = 1 )

    hBKG_A = tree_EE2016_HIPM.getLoopTH1F(opts.input, 'hEEQCDSR_trackIxy')
    hBKG_B = tree_EE2016_HIPM.getLoopTH1F(opts.input, 'hEEQCDBCR_trackIxy')
    newbin = np.linspace(0., 25., 26)
    hBKG_A_rebin = hBKG_A.Rebin(len(newbin)-1, 'hBKG_A_rebin', newbin)
    hBKG_B_rebin = hBKG_B.Rebin(len(newbin)-1, 'hBKG_B_rebin', newbin)
    makeClosureTestMC(lumi = '', name = 'QCD_EE_2016HIPM', hBKG_A = hBKG_A_rebin, hBKG_B = hBKG_B_rebin, ylog = True, tree = tree_EE2016_HIPM, inputdir = opts.input, labelB = 'Control Region: |#Delta#Phi|_{ee} > #pi/2', labelA = 'Signal Region: |#Delta#Phi|_{ee} < #pi/2', xlabel = '|d_{xy}|/#sigma_{d}', outtag = 'EEChannelV2', yshift = 0.0, LLlabel = 'EE', DATAlabel = 'HIP affected runs', extralabel = 'QCD Control Region', rmax = 3.0)

    hBKG_A = tree_MM2016_HIPM.getLoopTH1F(opts.input, 'hMMQCDSR_trackIxy')
    hBKG_B = tree_MM2016_HIPM.getLoopTH1F(opts.input, 'hMMQCDBCR_trackIxy')
    newbin = np.linspace(0., 25., 26)
    hBKG_A_rebin = hBKG_A.Rebin(len(newbin)-1, 'hBKG_A_rebin', newbin)
    hBKG_B_rebin = hBKG_B.Rebin(len(newbin)-1, 'hBKG_B_rebin', newbin)
    makeClosureTestMC(lumi = '', name = 'QCD_MM_2016HIPM', hBKG_A = hBKG_A_rebin, hBKG_B = hBKG_B_rebin, ylog = True, tree = tree_MM2016_HIPM, inputdir = opts.input, labelB = 'Control Region: |#Delta#Phi|_{#mu#mu} > #pi/2', labelA = 'Signal Region: |#Delta#Phi|_{ee} < #pi/2', xlabel = '|d_{xy}|/#sigma_{d}', outtag = 'MMChannelV2', yshift = 0.0, LLlabel = 'MM', DATAlabel = 'HIP affected runs', extralabel = 'QCD Control Region', rmax = 3.0)
    lumiMuon['DoubleMuon_Run2016D'] = lumiD
    lumiMuon['DoubleMuon_Run2016E'] = lumiE
    lumiMuon['DoubleMuon_Run2016F'] = lumiF
    lumiMuon['DoubleMuon_Run2016G'] = lumiG
    lumiMuon['DoubleMuon_Run2016H'] = lumiH

    lumi_Muon = 0.0
    for dataset in DoubleMuon_list:
        lumi_Muon += lumiMuon[dataset]

    #filename = 'dat/Samples_cern_Legacy.dat'
    filename = 'dat/Samples_cern_fillingv2.dat'

    ### Tree SI Tree
    treeSI_400_50_Legacy = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'dat/Samples_cern_Legacy.dat', Signals_400_50, 'SI'),
                                       name='SI',
                                       isdata=0)

    ################################
    ######## DoubleEG Plots ########
    ################################

    #treeDATA = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG_list, 'DATA'), name = 'DATA', isdata = 1 )

    ##################################
    ######## DoubleMuon Plots ########
    ##################################

    treeDATA = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleMuon_list, 'DATA'),
                           name='DATA',
Example #14
0
    lumiH = 8.61
    lumi_total = lumiB + lumiC + lumiD + lumiE + lumiF + lumiG + lumiH  # luminosity
    lumi_list = [lumiB, lumiC, lumiD, lumiE, lumiF, lumiG, lumiH]

    filename = 'dat/Samples_cern_filling.dat'

    letter = ['B', 'C', 'D', 'E', 'F', 'G', 'H']

    ### -> Muon plots:
    MuonTrees = []
    for i in range(0, len(DoubleMuon_list)):
        dataset = DoubleMuon_list[i]
        lumi = lumi_list[i]

        treeEra = Sample.Tree(fileName=helper.selectSamples(
            WORKPATH + filename, [dataset], 'DATA'),
                              name='DATA',
                              isdata=1)
        MuonTrees.append(treeEra)

    makeQCDEstimationPlot(lumi_total,
                          'hMM_trackIxy',
                          True,
                          MuonTrees,
                          DoubleMuon_list,
                          WORKPATH + opts.Muoninput,
                          outtag='QCDEstimation',
                          LLlabel='MM')
    makeQCDEstimationPlot(lumi_total,
                          'hMM_trackDxy',
                          True,
                          MuonTrees,
Example #15
0
    Signals2016.append('HSS_400_50_10_'+year)
    Signals2016.append('HSS_400_50_100_'+year)
    Signals2016.append('HSS_400_150_1_'+year)
    Signals2016.append('HSS_400_150_10_'+year)
    Signals2016.append('HSS_400_150_100_'+year)
    Signals2016.append('HSS_600_150_1_'+year)
    Signals2016.append('HSS_600_150_10_'+year)
    Signals2016.append('HSS_600_150_100_'+year)
    Signals2016.append('HSS_1000_150_1_'+year)
    Signals2016.append('HSS_1000_150_10_'+year)
    Signals2016.append('HSS_1000_150_100_'+year)
    Signals2016.append('HSS_1000_350_1_'+year)
    Signals2016.append('HSS_1000_350_10_'+year)
    Signals2016.append('HSS_1000_350_100_'+year)

    treeSI = Sample.Tree( fileName = helper.selectSamples(GALAPAGOPATH + 'signals_'+year+'.dat', Signals2016, 'MC'), name = year, isdata = 0 )

    ###################################
    ####   Loop over tree events   ####
    ###################################

    cm = CutManager.CutManager()
    rates = {}
    for b in treeSI.blocks:
        for s in b.samples:
            rates[s.name] = {}
            rates[s.name]['total'] = 0.0
            rates[s.name]['passed'] = 0.0

            for t in s.ttrees:
                print(s.name, 'New tree with:', t.GetEntries())
    #    Signal.append('ScalarBosons_400_150_40')
    Signal.append('DisplacedSUSY_1500_494_160')
    Signal.append('DisplacedSUSY_1000_148_60')
    Signal.append('DisplacedSUSY_350_148_173')
    Signal.append('DisplacedSUSY_120_48_165')

    ############## Data definition
    Data = []
    Data.append('DoubleMuon-Run2016B')

    ############# Parameter definition
    lumi = 36.773  # luminosity

    ############# Tree creation
    treeMC = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/MC.dat', Backgrounds, 'MC'), 'MC',
        0, WORKPATH + opts.outputFile)
    treeSI = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/SI.dat', Signal, 'SI'), 'SI', 0,
        WORKPATH + opts.outputFile)
    treeDATA = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/DATA.dat', Data, 'DATA'), 'DATA',
        1, WORKPATH + opts.outputFile)

    ############# Tree loop
    if not opts.avoidLoop:
        treeMC.Loop(lumi, False, False)
        treeSI.Loop(lumi, False, False)
        treeDATA.Loop(lumi, False, False)

    makeSensitivity(lumi, treeSI, treeMC, 'SR_EEsel_minIxy', 'SR_EEsel_minIxy',
Example #17
0
        makeDataMCPlot(lumiEG[dataset], 'hEE_trackDxy', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hEE_Lxy', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hEE_Ixy', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hEE_leadingPt', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hEE_subleadingPt', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hEE_normalizedChi2', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hE_eta', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hE_dxy', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hE_dxyError', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
        makeDataMCPlot(lumiEG[dataset], 'hE_charge', True, treeMC, treeDATA, WORKPATH + opts.EGinput, outtag = dataset, LLlabel = 'EE', DATAlabel = dataset, extralabel = '|Control region #Delta#Phi| > #pi/2')
    """

    ##### Joint luminosity

    treeMC = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       Backgrounds, 'MC'),
                         name='MC',
                         isdata=0)
    treeDATA = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleEG_list, 'DATA'),
                           name='DATA',
                           isdata=1)

    makeDataMCPlot(lumi_EG,
                   'hEEOS0_dPhi',
                   'hEESS0_dPhi',
                   True,
                   treeMC,
                   treeDATA,
                   WORKPATH + opts.EGinput,
                   outtag='DoubleEG_Full2016',
                   LLlabel='EE',
Example #18
0
    #### -----------------
    #### ---- Histograms
    #### -----------------

    hist_2d_BPregion = r.TH2F("hist_2d_BPregion", "", 150, -5, 5, 150, -5, 5)
    hist_2d_20region = r.TH2F("hist_2d_20region", "", 200, -20, 20, 200, -20,
                              20)
    hist_1d_r = r.TH1F("hist_1d_r_all", "", 100, 0, 10)

    #########################
    ####   Load sample   ####
    #########################

    treeA = Sample.Tree(fileName=helper.selectSamples(
        GALAPAGOPATH + 'dat/Samples_cern_UltraLegacy.dat',
        ['DoubleMuon_Run2018' + opts.era], 'DATA'),
                        name='2018' + opts.era,
                        isdata=0)

    ###################################
    ####   Loop over tree events   ####
    ###################################
    cm = CutManager.CutManager()

    for b in treeA.blocks:
        for s in b.samples:
            #for f in s.ftpaths:
            #    print(f)
            for t in s.ttrees:
                print('New tree with:', t.GetEntries())
                cutoff = t.GetEntries() / 10
    mass_rebin =  np.concatenate((np.arange(0, 15, 5, float), 
                                  np.arange(15, 65, 10, float), 
                                  np.arange(65, 100, 5, float), 
                                  np.arange(100, 220, 15, float), 
                                  np.arange(220, 400, 20, float)))
#                                  np.arange(15, 65, 10, float), 
#                                  np.arange(100, 400, 15, float)))


    Ixy_reb = [0.0, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 14.0, 20.0, 30.0, 40.0]
    Ixy_rebin = np.array(Ixy_reb)

    ################################
    ######## DoubleEG Plots ########
    ################################
    treeDATA_HIPM = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG_HIPM, 'DATA'), name = 'DATA', isdata = 1 )
    treeDATA_noHIPM = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG_noHIPM, 'DATA'), name = 'DATA', isdata = 1 )
    treeDATA_2016 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG_HIPM + DoubleEG_noHIPM, 'DATA'), name = 'DATA', isdata = 1 )
    treeDATA_2017 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG2017, 'DATA'), name = 'DATA', isdata = 1 )
    treeDATA_2018 = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, EGamma2018, 'DATA'), name = 'DATA', isdata = 1 )
    treeDATA_full = Sample.Tree( fileName = helper.selectSamples(WORKPATH + filename, DoubleEG_HIPM + DoubleEG_noHIPM + DoubleEG2017 + EGamma2018, 'DATA'), name = 'DATA', isdata = 1 )

    #### Prompt validation

    makePromptBKGPlot(name = 'EEprompt_mass_HIPM', lumi = 19.7, hname_SR = 'hEEpromptSR_mass', hname_CR = 'hEEpromptCR_mass', ylog = True, treeDATA = treeDATA_HIPM, inputdir = opts.input, xlabel = '', outtag = '', yshift = 0.0, LLlabel = 'EE', DATAlabel = '', extralabel = 'Prompt control region', xlog = False) 
    makePromptBKGPlot(name = 'EEprompt_mass_noHIPM', lumi = 16.15, hname_SR = 'hEEpromptSR_mass', hname_CR = 'hEEpromptCR_mass', ylog = True, treeDATA = treeDATA_noHIPM, inputdir = opts.input, xlabel = '', outtag = '', yshift = 0.0, LLlabel = 'EE', DATAlabel = '', extralabel = 'Prompt control region', xlog = False) 
    makePromptBKGPlot(name = 'EEprompt_mass_2016', lumi = 35.9, hname_SR = 'hEEpromptSR_mass', hname_CR = 'hEEpromptCR_mass', ylog = True, treeDATA = treeDATA_2016, inputdir = opts.input, xlabel = '', outtag = '', yshift = 0.0, LLlabel = 'EE', DATAlabel = '', extralabel = 'Prompt control region', xlog = False) 
    makePromptBKGPlot(name = 'EEprompt_mass_2017', lumi = 41.5, hname_SR = 'hEEpromptSR_mass', hname_CR = 'hEEpromptCR_mass', ylog = True, treeDATA = treeDATA_2017, inputdir = opts.input, xlabel = '', outtag = '', yshift = 0.0, LLlabel = 'EE', DATAlabel = '', extralabel = 'Prompt control region', xlog = False) 
    makePromptBKGPlot(name = 'EEprompt_mass_2018', lumi = 59.8, hname_SR = 'hEEpromptSR_mass', hname_CR = 'hEEpromptCR_mass', ylog = True, treeDATA = treeDATA_2018, inputdir = opts.input, xlabel = '', outtag = '', yshift = 0.0, LLlabel = 'EE', DATAlabel = '', extralabel = 'Prompt control region', xlog = False) 

    #### On-Z validation
Example #20
0
    lumiMuon['DoubleMuon_Run2016G'] = lumiG
    lumiMuon['DoubleMuon_Run2016H'] = lumiH

    lumi_Muon = 0.0
    for dataset in DoubleMuon_list:
        lumi_Muon += lumiMuon[dataset]

    filename = 'dat/Samples_cern_filling.dat'

    ################################
    ######## DoubleEG Plots ########
    ################################

    ## Full luminosity
    treeSI = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       Signals, 'MC'),
                         name='SI',
                         isdata=0)
    treeMC = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       Backgrounds, 'MC'),
                         name='MC',
                         isdata=0)
    treeMuon = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, DoubleMuon_list, 'DATA'),
                           name='DATA',
                           isdata=1)
    treeEG = Sample.Tree(fileName=helper.selectSamples(WORKPATH + filename,
                                                       DoubleEG_list, 'DATA'),
                         name='DATA',
                         isdata=1)

    makeSignalBackgroundPlot(hname='hMM_dPhi_full',
Example #21
0
    ############# Set the TDR plot style
    gROOT.ProcessLine('.L include/tdrstyle.C')
    gROOT.SetBatch(1)
    r.setTDRStyle()

    ############# Datasets definition
    MuonData = []
    MuonData.append('DoubleMuon-Run2016B')
    ElectronData = []
    ElectronData.append('DoubleEG-Run2016B')

    lumi = 4.8

    ############# Tree creation
    treeMuonDATA = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/DATA.dat', MuonData, 'DATA'),
        'DATA', 1, WORKPATH + opts.inputFile)
    treeElectronDATA = Sample.Tree(
        helper.selectSamples(WORKPATH + 'dat/DATA.dat', ElectronData, 'DATA'),
        'DATA', 1, WORKPATH + opts.inputFile)

    #makeBackgroundValidation(lumi, treeMC, 'EEsel_leadingPt', 'EEsel_leadingPt', 'Leading p_{T} (GeV/c)', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_subleadingPt', 'EEsel_subleadingPt', 'Subleading p_{T} (GeV/c)', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_invMass', 'EEsel_invMass', 'Mass (GeV/c^{2})', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_Chi2', 'EEsel_Chi2', 'Vertex #Chi^{2}', 1, 'EE')
    #makeBackgroundValidation(lumi, treeMC, 'EEsel_dPhi', 'EEsel_dPhi', 'Collinearity |#Delta#Phi|', 1, 'EE')
    makeCumulativeValidation(lumi, treeElectronDATA, 'SiF_EEsel_minIxy',
                             'SiF_EEsel_minIxy', '|d_{0}|/#sigma_{d}', 1, 'EE')

    #makeBackgroundValidation(lumi, treeMC, 'MMsel_leadingPt', 'MMsel_leadingPt', 'Leading p_{T} (GeV/c)', 1, 'MM')
    #makeBackgroundValidation(lumi, treeMC, 'MMsel_subleadingPt', 'MMsel_subleadingPt', 'Subleading p_{T} (GeV/c)', 1, 'MM')
Example #22
0
def createDatacards(datacards, Backgrounds, Signals, flavor, year):

    treeBKG = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + filename, Backgrounds, 'DATA'),
                          name='DATA',
                          isdata=1)
    datacard_list = []

    for datacard_key in datacards.keys():

        datacard = datacards[datacard_key]
        channels = {}

        ### Initialize channels with background information
        for channel_name in datacard.keys():

            xmin = datacard[channel_name]['bkg']['limits'][0]  # minimum value
            xmax = datacard[channel_name]['bkg']['limits'][1]  # minimum value
            directory = datacard[channel_name]['bkg']['dir']
            histogram = datacard[channel_name]['bkg']['histogram']

            print('>>>>> Info channel', channel_name, xmin, xmax, directory,
                  histogram)

            channels[channel_name] = DatacardManager.Channel(
                channel_name, xmin, xmax)

            ## Get histogram
            _histo = treeBKG.getLoopTH1F(directory, histogram)
            print(directory, histogram)
            c1 = r.TCanvas("", "", 500, 500)
            c1.SetLogy(1)
            _histo.Draw('HIST')
            c1.Print('Pruebafondochannel.png')
            channels[channel_name].addBackground('bkg', _histo)
            print(channels[channel_name].backgrounds[0].rate)

        for sample in Signals:

            treeSI = Sample.Tree(fileName=helper.selectSamples(
                WORKPATH + 'signals_' + year + '.dat', [sample], 'SI'),
                                 name='SI',
                                 isdata=0)

            sample_split = sample.split('_')
            mH = sample_split[1]
            mS = sample_split[2]
            ctau = sample_split[3]
            sample_label = 'mH' + mH + '__' + 'mS' + mS + '__' + 'ctau' + ctau + 'mm'

            ## Create datacard:
            datacard_name = 'Datacard__' + flavor + '__' + sample_label + '__' + year + '.txt'
            output_datacard = DatacardManager.Datacard(datacard_name)

            for channel_name in datacard.keys():
                histogram = datacard[channel_name]['sig']['histogram']
                directory = datacard[channel_name]['sig']['dir']
                _histo = treeSI.getLoopTH1F(directory, histogram)
                channels[channel_name].setSignal('sig', _histo)
                output_datacard.addChannel(channels[channel_name])

            output_datacard.saveDatacard(outputDir=_outdir)
            datacard_list.append(datacard_name)

    return datacard_list
Example #23
0
    ### Lista de senyales que queremos incluir (tercera columna del dat):
    Signals = []
    Signals.append('HXX_400_50_4mm')

    ############# DEFINICION DE PARAMETROS
    ###
    ### Este es el valor de la luminosidad al que se normalizan los plots e.g. 35.9 fb correspondiente a 2016
    lumi = 35.9  # luminosity

    ############# CREACION DE OBJETOS TREE DE GALAPAGO
    ###
    ### Toman como uno de los inputs la .dat file que queremos meter (en este caso dat/Samples_cern.dat)
    ### y una lista con los nombres de las muestras que queremos incluir de ese dat.
    ### Es importante indicar (cuando proceda) que isdata = 0 para que se aplique la normalizacion
    treeMC = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'dat/Samples_cern.dat', Backgrounds, 'MC'),
                         name='MC',
                         isdata=0)
    treeSI = Sample.Tree(fileName=helper.selectSamples(
        WORKPATH + 'dat/Samples_cern.dat', Signals, 'SI'),
                         name='SI',
                         isdata=0)

    ############# DEFINICION DE CORTES
    ### Como ejemplo pongo algunos de los cortes basicos de los displaced global muon pais (DMDM)
    ### Hay algunos definidos en include/CutManager, pero desde aqui podeis definir los que querais
    ### La sintaxis es la que se utilizaria con el metodo .Draw de un TTree normal

    cuts = CutManager.CutManager()  # Clase CutManager
    haveDMDM = cuts.brackets('nDMDMBase > 0')  # Corte 1
    lowPhi = cuts.brackets(
        'fabs(DMDMBase_dPhi[DMDMBase_maxIxy])< 3.14/2.0')  # Corte 2
if __name__ == "__main__":

    print bcolors.HEADER
    print '#######################################################################'
    print '                  Starting IFCA   analysis...                          '
    print '#######################################################################' + bcolors.ENDC

    parser = optparse.OptionParser(usage='usage: %prog [opts] FilenameWithSamples', version='%prog 1.0')
    parser.add_option('-s', '--samples', action='store', type=str, dest='sampleFile', default='samples.dat', help='the samples file. default \'samples.dat\'')
    (opts, args) = parser.parse_args()

    daDatasets = ['Data']
    mcDatasets = ['DYJets', 'TTJets', 'singleT', 'TTW', 'TTZ', 'WW', 'VVV', 'VZ']


    treeMC = Sample.Tree(helper.selectSamples(opts.sampleFile, mcDatasets, 'MC'), 'MC'  , 0, isScan = 0)
    treeDA = Sample.Tree(helper.selectSamples(opts.sampleFile, daDatasets, 'DA'), 'DATA', 1, isScan = 0)

    lumi = 9.9 ; maxrun = 99276811; lumi_str = '9.9invfb'
    gROOT.ProcessLine('.L include/tdrstyle.C')
    gROOT.SetBatch(1)
    r.setTDRStyle()

    cuts = CutManager.CutManager()
   
    labelmll = 'm_{ll} [GeV]'
    labelmet = 'E_{T}^{miss} [GeV]'
    labelmt2 = 'MT2 [GeV]'
    labelpt2 = 'p_{T} (2nd) [GeV]'
    labelnjet = "N. Jets"