コード例 #1
0
def load(cms_base, energy):
    print("load model py", energy)
    model = NonResonantModel()
    if energy == 13:
        print("load model for 13 TeV")
        dumb = model.ReadCoefficients(
            cms_base +
            "/src/HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M_costHHSim_19-4.txt"
        )
    if energy == 14:
        print("load model for 14 TeV")
        model.ReadCoefficients2(14, cms_base)
    return model
コード例 #2
0
        '--verbose',
        dest='verbose',
        action='store_true',
        default=False,
        required=False,
        help='R|Verbose output',
    )
    args = parser.parse_args()
    era = args.era
    analysis_type = args.type

    if args.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    cmssw_base = os.environ['CMSSW_BASE']
    model = NonResonantModel()
    coef_file = os.path.join(
        cmssw_base,
        "src/HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M_costHHSim_19-4.txt"
    )
    assert (os.path.isfile(coef_file))
    coefs = model.ReadCoefficients(coef_file)
    hist_file = os.path.join(
        cmssw_base,
        "src/Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root")
    assert (os.path.isfile(hist_file))
    hist_title = "H1bin4"

    norm = []
    for scan_idx in range(len(klJHEP)):
        norm.append(
コード例 #3
0
def AddReWeightBranch(intree, newfilename, KL, CT, CG, C2G, C2T):

    cmssw_base = os.environ['CMSSW_BASE']

    outfile = TFile(newfilename, "RECREATE")

    model = NonResonantModel()
    #  dumb = model.ReadCoefficients(cmssw_base+"/src/HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M.txt")
    dumb = model.ReadCoefficients(
        cmssw_base +
        "/src/HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M_costHHSim_19-4.txt"
    )

    #  histfilename=cmssw_base+"/src/HiggsAnalysis/bbggLimits/data/NR_AnalyticalWeight/Hist2DSum_V0_SM_box.root"
    histfilename = cmssw_base + "/src/HHStatAnalysis/Support/NonResonant/HistSum2D_4b_rebin_SimCostHH_19-4.root"
    #  histtitle= "SumV0_AnalyticalBinExt"
    histtitle = "SumV0_AnalyticalBinExtSimCostHH"
    fileHH = TFile(histfilename)
    sumHAnalyticalBin = fileHH.Get(histtitle)
    print KL, CT, CG, C2G, C2T
    #need to turn kappa top = 0 to kappa top = very small, otherwise weights are 0
    if abs(CT) < 0.00001: CT = 0.00001
    calcSumOfWeights = model.getNormalization(KL, CT, C2T, CG, C2G,
                                              histfilename, histtitle)

    outtree = intree.CloneTree(0)
    new_evWeight = array('f', [0])
    NR_weight = array('f', [0])
    NR_kl = array('f', [0])
    NR_ct = array('f', [0])
    NR_cg = array('f', [0])
    NR_c2g = array('f', [0])
    NR_c2t = array('f', [0])
    _new_evWeight = outtree.Branch('new_evWeight', new_evWeight,
                                   'new_evWeight/F')
    _NR_weight = outtree.Branch('NR_weight', NR_weight, 'NR_weight/F')
    _NR_kl = outtree.Branch('NR_kl', NR_kl, 'NR_kl/F')
    _NR_ct = outtree.Branch('NR_ct', NR_ct, 'NR_ct/F')
    _NR_cg = outtree.Branch('NR_cg', NR_cg, 'NR_cg/F')
    _NR_c2t = outtree.Branch('NR_c2t', NR_c2t, 'NR_c2t/F')
    _NR_c2g = outtree.Branch('NR_c2g', NR_c2g, 'NR_c2g/F')
    nentries = intree.GetEntries()

    for i in range(0, nentries):
        if i % 1000 == 0: print i
        intree.GetEntry(i)

        NR_kl[0] = KL
        NR_ct[0] = CT
        NR_cg[0] = CG
        NR_c2t[0] = C2T
        NR_c2g[0] = C2G

        mhh = intree.gen_mHH
        cost = intree.gen_cosTheta
        mhhcost = [mhh, cost, 0, 0]

        bmhh = sumHAnalyticalBin.GetXaxis().FindBin(mhh)
        bcost = sumHAnalyticalBin.GetYaxis().FindBin(abs(cost))

        effSumV0 = sumHAnalyticalBin.GetBinContent(bmhh, bcost)

        #factor of 6 comes from the fact that the normalization of the weights has been calculated
        #with 300k events per node point, in bbgg we only have 6, so we are off by a factor of 30/5=6
        weight = 6 * model.getScaleFactor(mhh, cost, KL, CT, C2T, CG, C2G,
                                          effSumV0, calcSumOfWeights)

        NR_weight[0] = weight
        if 'bb' in str(intree.GetName()):
            new_evWeight[0] = (intree.genTotalWeight) * weight
        else:
            new_evWeight[0] = (
                intree.evWeight
            ) * weight * 50000.  #need to multiply by 50k since, in the limit trees, evWeight has been normalized by the #evs in MC

        outtree.Fill()

    outfile.cd()
    outtree.Write()
    outfile.Close()
コード例 #4
0
def load(coefFile):
    model = NonResonantModel()
    model.ReadCoefficients(coefFile)
    return model
コード例 #5
0
import os, sys, time, math
import shutil, subprocess
from HHStatAnalysis.AnalyticalModels.NonResonantModel import NonResonantModel

# ROOT imports
import ROOT
from ROOT import TChain, TH1F, TFile, vector, gROOT, TTree

##################
# read the histos tree and contruct the tree of the relevant variables
#path = "/lustre/cmswork/hh/alp_baseSelector/"
path = "/afs/cern.ch/user/l/lcadamur/public/4Xanda/"
#path = "/afs/cern.ch/user/a/andrey/public/HH/LT-Jan25-APZ_LowMass/"
outpath = "/afs/cern.ch/user/a/acarvalh/public/toTATABB/"
data = "../../../HHStatAnalysis/AnalyticalModels/data/"
model = NonResonantModel()
# obtaining BSM/SM coeficients
dumb = model.ReadCoefficients(
    "../../../HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_klkt.txt")

fileoutput = "events_SumV0_afterBaseline.root"
files = []
endfile = ".root"
files.append("tree_HH_SM_tautau")
#files.append("LT_output_GluGluToHHTo2B2G_node_box")
#for ifile in range(2,14) : files.append("LT_output_GluGluToHHTo2B2G_node_"+str(ifile))
# to analytical re
# We use only SM as input events by now
# read the 2D histo referent to the sum of events
fileHH = ROOT.TFile("../../../Support/NonResonant/HistSum2D_SMonly.root")
sumHAnalyticalBin = fileHH.Get("SumV0_AnalyticalBin")
コード例 #6
0
if not os.path.isfile(input_fn):
    raise ValueError("No such file: %s" % input_fn)

output_dir = os.path.dirname(output_fn)
if not os.path.isdir(output_dir):
    logging.warning("Creating directory: {}".format(output_dir))
    os.makedirs(output_dir)

input_file = ROOT.TFile.Open(input_fn, 'read')
assert (input_file)
input_tree = input_file.Get('Events')

mhh_br_name = 'mHH_lhe'
cost_br_name = 'cosThetaStar_lhe'

model = NonResonantModel()
denominator_process = Hist2D(model.binGenMHH,
                             model.binGenCostS,
                             name=process_name)
denominator_category = Hist2D(model.binGenMHH,
                              model.binGenCostS,
                              name=category_name)

nof_events = input_tree.GetEntries()
logging.debug("Input file {} has {} events".format(input_fn, nof_events))

has_evt_brs = not bool({mhh_br_name, cost_br_name} -
                       set(br.GetName()
                           for br in input_tree.GetListOfBranches()))
if has_evt_brs:
    logging.debug(
コード例 #7
0
def main():
  #if 1 > 0 :
  # declare the 2D ===> should be global variable
  model = NonResonantModel()
  # obtaining BSM/SM coeficients
  #dumb = model.ReadCoefficients("../data/coefficientsByBin_A1A3A7.txt") 
  dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M_costHHSim_19-4.txt") 
  #dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M.txt") 
  counteventSM=0
  sumWeight=0
  # now loop over events, calculate weights using the coeffitients and  plot histograms
  # We sum SM + box + the benchmarks from 2-13 
  # read the 2D histo referent to the sum of events
  #fileHH=ROOT.TFile("../../../Analysis/Support/NonResonant/Hist2DSum_V0_SM_box.root")
  #sumHAnalyticalBin = fileHH.Get("SumV0_AnalyticalBin")
  histfilename="../../../Analysis/Support/NonResonant/HistSum2D_4b_rebin_SimCostHH_19-4.root"
  #histtitle= "SumV0_AnalyticalBinExt" #
  histtitle= "SumV0_AnalyticalBinExtSimCostHH" #
  fileHH=ROOT.TFile(histfilename)
  sumHAnalyticalBin = fileHH.Get(histtitle)
  calcSumOfWeights = model.getNormalization(kl, kt,c2,cg,c2g,histfilename,histtitle)  # this input is flexible, tatabb may have only the SM
  # print "sum of weights calculated" , calcSumOfWeights 
  # read the events
  pathBenchEvents="/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/" #"/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/" # events to reweight   
  file=ROOT.TFile(pathBenchEvents+"events_SumV0.root")
  tree=file.Get("treeout")
  nev = tree.GetEntries()
  # declare the histograms 
  CalcMhh = np.zeros((nev))
  CalcCost = np.zeros((nev))
  CalcPtH = np.zeros((nev))
  CalcPtHH = np.zeros((nev))
  CalcWeight = np.zeros((nev))

  CalcPtHgg = np.zeros((nev))
  CalcMhhReco = np.zeros((nev))
  CalcMXReco = np.zeros((nev))

  countevent = 0
  #for kll in range(-5,5) : model.getNormalization(kll, kt,sumHBenchBin)
  for iev in range(0,nev) :
      tree.GetEntry(iev)
      mhh = tree.Genmhh
      cost = tree.GenHHCost

      mhhcost= [mhh,cost,0,0] # to store [mhh , cost] of that event
      # find the Nevents from the sum of events on that bin
      bmhh = sumHAnalyticalBin.GetXaxis().FindBin(mhh)
      bcost = sumHAnalyticalBin.GetYaxis().FindBin(abs(cost))
      #print (tree.GenHHCost,cost,bcost)
      effSumV0 = sumHAnalyticalBin.GetBinContent(bmhh,abs(bcost))  # quantity of simulated events in that bin (without cuts)
      weight = model.getScaleFactor(mhh , cost,kl, kt,c2,cg,c2g, effSumV0 , calcSumOfWeights)   # model.effSM,model.MHH,model.COSTS,model.A1,model.A3,model.A7, effSumV0) 
      #############################################
      # fill histograms to test
      #############################################
      if weight > 0: 
               #print countevent
               CalcMhh[countevent] = float(mhhcost[0]) 
               CalcCost[countevent] = float(abs(mhhcost[1])) 
               CalcPtH[countevent] = float(mhhcost[2]) 
               CalcPtHH[countevent] = float(mhhcost[3]) 
               CalcWeight[countevent] = weight 
               countevent+=1
               sumWeight+=weight
  print "plotted histogram reweighted from ",countevent," events, ", float(100*(nev-countevent)/nev)," % of the events was lost in empty bins in SM simulation"
  print "sum of weights",sumWeight
  ############################################################################################################################
  # Draw test histos
  ###############################################
  drawtest =0 
  nevtest=50000
  if kl == 1 and kt == 1 and c2 ==0 and cg == 0 and c2g ==0 : 
     filne = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_0.lhe.decayed"    # 0 is SM
     nevtest = 100000
     drawtest = 1 
  # BSM events
  pathBSMtest="/afs/cern.ch/work/a/acarvalh/generateHH/asciiHH_tofit/GF_HH_toRecursive/" # events of file to superimpose a test
  # see the translation of coefficients for this last on: If you make this script smarter (to only read files we ask to test) you can implement more
  # https://github.com/acarvalh/generateHH/blob/master/fit_GF_HH_lhe/tableToFitA3andA7.txt
  if kl == -10 and kt == 0.5 and c2 ==0 and cg == 0 and c2g ==0 :
     drawtest =1
     filne = pathBSMtest+"GF_HH_42.lhe.decayed"
  if kl == 0.0001 and kt == 2.25 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_9.lhe.decayed"
  if kl == 2.5 and kt == 1.0 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_60.lhe.decayed"
  klJHEP=[1.0, 7.5,  1.0,  1.0,  -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0]
  ktJHEP=[1.0, 1.0,  1.0,  1.0,  1.5,  1.0, 1.0, 1.0, 1.0,  1.0, 1.5,  1.0, 1.0]
  c2JHEP=[0.0, -1.0, 0.5, -1.5, -3.0,  0.0, 0.0, 0.0, 0.0,  1.0, -1.0, 0.0, 1.0]
  cgJHEP=[0.0, 0.0, 0.6,  0.0, 0.0,   0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0]
  c2gJHEP=[0.0, 0.0, 1.0, -0.8, 0.0, -1.0, -0.2,-0.2,  1.0,  0.6, 0.0, -1.0, 0.0]
  # python recastHH.py --kl 7.5 --kt 1 --c2 -1
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.5 --cg -0.8 --c2g 0.6
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 -1.5 --cg 0.0 --c2g -0.8
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.0 --cg 0.8 --c2g -1.0
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 1.0 --cg -0.6 --c2g 0.6
  for sam in range(0,13):
    #print (sam, ktJHEP[sam] , kt , klJHEP[sam] , c2 ,c2JHEP[sam] , cg , cgJHEP[sam] , c2g , c2gJHEP[sam])
    if kl == klJHEP[sam] and kt == ktJHEP[sam] and c2 ==c2JHEP[sam] and cg == cgJHEP[sam] and c2g ==c2gJHEP[sam] : 
       print sam
       filne="/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_"+str(sam)+".lhe.decayed"
       nevtest=100000
       drawtest = sam 
  ############################################################################################################################
  CalcMhhTest = np.zeros((nevtest))
  CalcCostTest = np.zeros((nevtest))
  CalcPtHTest = np.zeros((nevtest))
  CalcPtHHTest = np.zeros((nevtest))

  CalcPtHggTest = np.zeros((nevtest))
  CalcMhhRecoTest = np.zeros((nevtest))
  CalcMXRecoTest = np.zeros((nevtest))
  if options.doPlot : 
    print "draw plain histogram to test"
    model.LoadTestEvents(CalcMhhTest,CalcCostTest,CalcPtHTest,CalcPtHHTest,filne)  
    model.plotting(kl,kt,c2,cg,c2g,CalcMhh,CalcCost,CalcPtHgg,CalcPtHH,CalcMhhReco,CalcMXReco,CalcWeight,CalcMhhTest,CalcCostTest,CalcPtHggTest,CalcPtHHTest,CalcMhhRecoTest,CalcMXRecoTest,drawtest)
コード例 #8
0
    def __init__(self,
                 era,
                 use_lhe=True,
                 use_gen=False,
                 compute_weights=False):
        self.use_gen = use_gen
        self.use_lhe = use_lhe
        assert (self.use_gen or self.use_lhe)
        self.compute_weights = compute_weights

        if self.use_gen:
            print(
                "Computing di-Higgs variables from generator-level Higgs bosons"
            )
        else:
            print(
                "NOT computing di-Higgs variables from generator-level Higgs bosons"
            )
        if self.use_lhe:
            print(
                "Computing di-Higgs variables from LHE parton-level Higgs bosons"
            )
        else:
            print(
                "NOT computing di-Higgs variables from LHE parton-level Higgs bosons"
            )
        if self.compute_weights:
            print("Also computing the di-Higgs event-level weights")
        else:
            print("NOT computing the di-Higgs event-level weights")

        mHH_name = "mHH"
        cosThetaStar_name = "cosThetaStar"
        gen_suffix = "gen"
        lhe_suffix = "lhe"

        self.mHH_genName = "{}_{}".format(mHH_name, gen_suffix)
        self.cosThetaStar_genName = "{}_{}".format(cosThetaStar_name,
                                                   gen_suffix)
        self.mHH_lheName = "{}_{}".format(mHH_name, lhe_suffix)
        self.cosThetaStar_lheName = "{}_{}".format(cosThetaStar_name,
                                                   lhe_suffix)

        weightBaseName = "HHWeight"
        BMName = "BM"
        scanName = "scan"

        self.nofWeightsBMName = "n{}_{}".format(weightBaseName, BMName)
        self.weightBM_genName = "{}_{}_{}".format(weightBaseName, BMName,
                                                  gen_suffix)
        self.weightBM_lheName = "{}_{}_{}".format(weightBaseName, BMName,
                                                  lhe_suffix)

        self.nofWeightsScanName = "n{}_{}".format(weightBaseName, scanName)
        self.weightScan_genName = "{}_{}_{}".format(weightBaseName, scanName,
                                                    gen_suffix)
        self.weightScan_lheName = "{}_{}_{}".format(weightBaseName, scanName,
                                                    lhe_suffix)

        os.environ["MKL_NUM_THREADS"] = "1"

        cmssw_base = os.path.join(os.environ['CMSSW_BASE'], "src")
        coeffFile = os.path.join(
            cmssw_base,
            "HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M_costHHSim_19-4.txt"
        )
        self.model = None
        if self.compute_weights:
            assert (os.path.isfile(coeffFile))
            self.model = NonResonantModel()
            self.model.ReadCoefficients(coeffFile)

        denominatorHistogramName = "denominator_reweighting"
        denominatorFile = os.path.join(
            cmssw_base,
            "hhAnalysis/bbww/data/denominator_reweighting_bbvv_{}.root".format(
                era))
        self.denominatorFilePtr = None
        self.denominatorHistogram = None
        if self.compute_weights:
            assert (os.path.isfile(denominatorFile))
            self.denominatorFilePtr = ROOT.TFile.Open(denominatorFile, "READ")
            assert (self.denominatorFilePtr)
            assert (denominatorHistogramName in [
                key.GetName()
                for key in self.denominatorFilePtr.GetListOfKeys()
            ])
            self.denominatorHistogram = self.denominatorFilePtr.Get(
                denominatorHistogramName)

        scanFile = os.path.join(cmssw_base, "hhAnalysis/bbww/data/kl_scan.dat")
        self.nofWeightsScan = 0
        self.klScan = []
        self.ktScan = []
        self.c2Scan = []
        self.cgScan = []
        self.c2gScan = []
        self.BM_klScan = []
        self.Norm_klScan = []
        if self.compute_weights:
            assert (os.path.isfile(scanFile))
            with open(scanFile, 'r') as scanFileObj:
                for line in scanFileObj:
                    line_split = line.rstrip('\n').split()
                    if len(line_split) != 7:
                        continue
                    self.klScan.append(float(line_split[0]))
                    self.ktScan.append(float(line_split[1]))
                    self.c2Scan.append(float(line_split[2]))
                    self.cgScan.append(float(line_split[3]))
                    self.c2gScan.append(float(line_split[4]))
                    self.BM_klScan.append(float(line_split[5]))
                    self.Norm_klScan.append(float(line_split[6]))
            self.nofWeightsScan = len(self.klScan)
            assert (len(self.ktScan) == self.nofWeightsScan
                    and len(self.c2Scan) == self.nofWeightsScan
                    and len(self.cgScan) == self.nofWeightsScan
                    and len(self.c2gScan) == self.nofWeightsScan
                    and len(self.BM_klScan) == self.nofWeightsScan
                    and len(self.Norm_klScan) == self.nofWeightsScan)
            print("Using %d points to scan" % self.nofWeightsScan)

        normFile = os.path.join(
            cmssw_base,
            "Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root")
        normHist = "H1bin4"
        self.nofWeightsBM = 13
        self.klJHEP = [
            1.0, 7.5, 1.0, 1.0, -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0
        ]
        self.ktJHEP = [
            1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0
        ]
        self.c2JHEP = [
            0.0, -1.0, 0.5, -1.5, -3.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 1.0
        ]
        self.cgJHEP = [
            0.0, 0.0, -0.8, 0.0, 0.0, 0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0
        ]
        self.c2gJHEP = [
            0.0, 0.0, 0.6, -0.8, 0.0, -1.0, -0.2, -0.2, 1.0, 0.6, 0.0, -1.0,
            0.0
        ]
        assert (len(self.klJHEP) == self.nofWeightsBM
                and len(self.ktJHEP) == self.nofWeightsBM
                and len(self.c2JHEP) == self.nofWeightsBM
                and len(self.cgJHEP) == self.nofWeightsBM
                and len(self.c2gJHEP) == self.nofWeightsBM)
        self.normJHEP = []
        if self.compute_weights:
            assert (os.path.isfile(normFile))
            for idx in range(self.nofWeightsBM):
                normJHEPval = self.model.getNormalization(
                    self.klJHEP[idx], self.ktJHEP[idx], self.c2JHEP[idx],
                    self.cgJHEP[idx], self.c2gJHEP[idx], normFile, normHist)
                self.normJHEP.append(normJHEPval)
            assert (len(self.normJHEP) == self.nofWeightsBM)
            print("Using %d JHEP BMs" % self.nofWeightsBM)
コード例 #9
0
class diHiggsVarProducer(Module):
    def __init__(self,
                 era,
                 use_lhe=True,
                 use_gen=False,
                 compute_weights=False):
        self.use_gen = use_gen
        self.use_lhe = use_lhe
        assert (self.use_gen or self.use_lhe)
        self.compute_weights = compute_weights

        if self.use_gen:
            print(
                "Computing di-Higgs variables from generator-level Higgs bosons"
            )
        else:
            print(
                "NOT computing di-Higgs variables from generator-level Higgs bosons"
            )
        if self.use_lhe:
            print(
                "Computing di-Higgs variables from LHE parton-level Higgs bosons"
            )
        else:
            print(
                "NOT computing di-Higgs variables from LHE parton-level Higgs bosons"
            )
        if self.compute_weights:
            print("Also computing the di-Higgs event-level weights")
        else:
            print("NOT computing the di-Higgs event-level weights")

        mHH_name = "mHH"
        cosThetaStar_name = "cosThetaStar"
        gen_suffix = "gen"
        lhe_suffix = "lhe"

        self.mHH_genName = "{}_{}".format(mHH_name, gen_suffix)
        self.cosThetaStar_genName = "{}_{}".format(cosThetaStar_name,
                                                   gen_suffix)
        self.mHH_lheName = "{}_{}".format(mHH_name, lhe_suffix)
        self.cosThetaStar_lheName = "{}_{}".format(cosThetaStar_name,
                                                   lhe_suffix)

        weightBaseName = "HHWeight"
        BMName = "BM"
        scanName = "scan"

        self.nofWeightsBMName = "n{}_{}".format(weightBaseName, BMName)
        self.weightBM_genName = "{}_{}_{}".format(weightBaseName, BMName,
                                                  gen_suffix)
        self.weightBM_lheName = "{}_{}_{}".format(weightBaseName, BMName,
                                                  lhe_suffix)

        self.nofWeightsScanName = "n{}_{}".format(weightBaseName, scanName)
        self.weightScan_genName = "{}_{}_{}".format(weightBaseName, scanName,
                                                    gen_suffix)
        self.weightScan_lheName = "{}_{}_{}".format(weightBaseName, scanName,
                                                    lhe_suffix)

        os.environ["MKL_NUM_THREADS"] = "1"

        cmssw_base = os.path.join(os.environ['CMSSW_BASE'], "src")
        coeffFile = os.path.join(
            cmssw_base,
            "HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_extended_3M_costHHSim_19-4.txt"
        )
        self.model = None
        if self.compute_weights:
            assert (os.path.isfile(coeffFile))
            self.model = NonResonantModel()
            self.model.ReadCoefficients(coeffFile)

        denominatorHistogramName = "denominator_reweighting"
        denominatorFile = os.path.join(
            cmssw_base,
            "hhAnalysis/bbww/data/denominator_reweighting_bbvv_{}.root".format(
                era))
        self.denominatorFilePtr = None
        self.denominatorHistogram = None
        if self.compute_weights:
            assert (os.path.isfile(denominatorFile))
            self.denominatorFilePtr = ROOT.TFile.Open(denominatorFile, "READ")
            assert (self.denominatorFilePtr)
            assert (denominatorHistogramName in [
                key.GetName()
                for key in self.denominatorFilePtr.GetListOfKeys()
            ])
            self.denominatorHistogram = self.denominatorFilePtr.Get(
                denominatorHistogramName)

        scanFile = os.path.join(cmssw_base, "hhAnalysis/bbww/data/kl_scan.dat")
        self.nofWeightsScan = 0
        self.klScan = []
        self.ktScan = []
        self.c2Scan = []
        self.cgScan = []
        self.c2gScan = []
        self.BM_klScan = []
        self.Norm_klScan = []
        if self.compute_weights:
            assert (os.path.isfile(scanFile))
            with open(scanFile, 'r') as scanFileObj:
                for line in scanFileObj:
                    line_split = line.rstrip('\n').split()
                    if len(line_split) != 7:
                        continue
                    self.klScan.append(float(line_split[0]))
                    self.ktScan.append(float(line_split[1]))
                    self.c2Scan.append(float(line_split[2]))
                    self.cgScan.append(float(line_split[3]))
                    self.c2gScan.append(float(line_split[4]))
                    self.BM_klScan.append(float(line_split[5]))
                    self.Norm_klScan.append(float(line_split[6]))
            self.nofWeightsScan = len(self.klScan)
            assert (len(self.ktScan) == self.nofWeightsScan
                    and len(self.c2Scan) == self.nofWeightsScan
                    and len(self.cgScan) == self.nofWeightsScan
                    and len(self.c2gScan) == self.nofWeightsScan
                    and len(self.BM_klScan) == self.nofWeightsScan
                    and len(self.Norm_klScan) == self.nofWeightsScan)
            print("Using %d points to scan" % self.nofWeightsScan)

        normFile = os.path.join(
            cmssw_base,
            "Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root")
        normHist = "H1bin4"
        self.nofWeightsBM = 13
        self.klJHEP = [
            1.0, 7.5, 1.0, 1.0, -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0
        ]
        self.ktJHEP = [
            1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0
        ]
        self.c2JHEP = [
            0.0, -1.0, 0.5, -1.5, -3.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 1.0
        ]
        self.cgJHEP = [
            0.0, 0.0, -0.8, 0.0, 0.0, 0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0
        ]
        self.c2gJHEP = [
            0.0, 0.0, 0.6, -0.8, 0.0, -1.0, -0.2, -0.2, 1.0, 0.6, 0.0, -1.0,
            0.0
        ]
        assert (len(self.klJHEP) == self.nofWeightsBM
                and len(self.ktJHEP) == self.nofWeightsBM
                and len(self.c2JHEP) == self.nofWeightsBM
                and len(self.cgJHEP) == self.nofWeightsBM
                and len(self.c2gJHEP) == self.nofWeightsBM)
        self.normJHEP = []
        if self.compute_weights:
            assert (os.path.isfile(normFile))
            for idx in range(self.nofWeightsBM):
                normJHEPval = self.model.getNormalization(
                    self.klJHEP[idx], self.ktJHEP[idx], self.c2JHEP[idx],
                    self.cgJHEP[idx], self.c2gJHEP[idx], normFile, normHist)
                self.normJHEP.append(normJHEPval)
            assert (len(self.normJHEP) == self.nofWeightsBM)
            print("Using %d JHEP BMs" % self.nofWeightsBM)

    def beginJob(self):
        pass

    def endJob(self):
        pass

    def beginFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
        self.out = wrappedOutputTree
        if self.use_gen:
            self.out.branch(self.mHH_genName, "F")
            self.out.branch(self.cosThetaStar_genName, "F")
        if self.use_lhe:
            self.out.branch(self.mHH_lheName, "F")
            self.out.branch(self.cosThetaStar_lheName, "F")
        if self.compute_weights:
            self.out.branch(self.nofWeightsBMName, "I")
            self.out.branch(self.nofWeightsScanName, "I")
            if self.use_gen:
                self.out.branch(self.weightBM_genName,
                                "F",
                                lenVar=self.nofWeightsBMName)
                self.out.branch(self.weightScan_genName,
                                "F",
                                lenVar=self.nofWeightsScanName)
            if self.use_lhe:
                self.out.branch(self.weightBM_lheName,
                                "F",
                                lenVar=self.nofWeightsBMName)
                self.out.branch(self.weightScan_lheName,
                                "F",
                                lenVar=self.nofWeightsScanName)

    def endFile(self, inputFile, outputFile, inputTree, wrappedOutputTree):
        if self.denominatorFilePtr:
            self.denominatorFilePtr.Close()

    def get_denominator(self, mHH, cosThetaStar):
        assert (self.denominatorHistogram)
        mHH_bin = self.denominatorHistogram.GetXaxis().FindBin(mHH)
        cosThetaStar_bin = self.denominatorHistogram.GetYaxis().FindBin(
            abs(cosThetaStar))
        return self.denominatorHistogram.GetBinContent(mHH_bin,
                                                       cosThetaStar_bin)

    def compute(self, higgses):
        higgs_lead_p4, higgs_sublead_p4 = get_p4_pair(higgses)
        higgs_pair_p4 = higgs_lead_p4 + higgs_sublead_p4
        mHH = higgs_pair_p4.M()

        # boost leading or subleading Higgs -- doesn't matter
        higgs_lead_p4.Boost(-higgs_pair_p4.BoostVector())
        cosThetaStar = abs(higgs_lead_p4.CosTheta())
        denominator = self.get_denominator(
            mHH, cosThetaStar) if self.compute_weights else 1.

        weightsBM = [0.] * self.nofWeightsBM
        if self.compute_weights:
            weightsBM = []
            for bmIdx in range(self.nofWeightsBM):
                weightBM = self.model.getScaleFactor(
                    mhh=mHH,
                    cost=cosThetaStar,
                    kl=self.klJHEP[bmIdx],
                    kt=self.ktJHEP[bmIdx],
                    c2=self.c2JHEP[bmIdx],
                    cg=self.cgJHEP[bmIdx],
                    c2g=self.c2gJHEP[bmIdx],
                    effSumV0=denominator,
                    Cnorm=self.normJHEP[bmIdx],
                )
                weightsBM.append(weightBM)

        weightsScan = [0.] * self.nofWeightsScan
        if self.compute_weights:
            weightsScan = []
            for scanIdx in range(self.nofWeightsScan):
                weightScan = self.model.getScaleFactor(
                    mhh=mHH,
                    cost=cosThetaStar,
                    kl=self.klScan[scanIdx],
                    kt=self.ktScan[scanIdx],
                    c2=self.c2Scan[scanIdx],
                    cg=self.cgScan[scanIdx],
                    c2g=self.c2gScan[scanIdx],
                    effSumV0=denominator,
                    Cnorm=self.Norm_klScan[scanIdx],
                )
                weightsScan.append(weightScan)

        return mHH, cosThetaStar, weightsBM, weightsScan

    def analyze(self, event):

        weightsBM_gen = [0.] * self.nofWeightsBM
        weightsScan_gen = [0.] * self.nofWeightsScan
        mHH_gen, cosThetaStar_gen = -1., -2.
        if self.use_gen:
            genParticles = Collection(event, "GenPart")
            higgses_gen = sorted(
              filter(
                lambda genPart:
                  genPart.pdgId == 25 and \
                  (genParticles[genPart.genPartIdxMother].pdgId != 25 if genPart.genPartIdxMother >= 0 else True),
                genParticles
              ),
              key = lambda genHiggs: genHiggs.pt,
              reverse = True
            )
            nofHiggs_gen = len(higgses_gen)

            if nofHiggs_gen == 2:
                mHH_gen, cosThetaStar_gen, weightsBM_gen, weightsScan_gen = self.compute(
                    higgses_gen)
            else:
                print(
                    "Found an event that has not exactly two Higgs bosons at the generator level"
                )

        weightsBM_lhe = [0.] * self.nofWeightsBM
        weightsScan_lhe = [0.] * self.nofWeightsScan
        mHH_lhe, cosThetaStar_lhe = -1., -2.
        if self.use_lhe:
            lheParticles = Collection(event, "LHEPart")
            higgses_lhe = sorted(
                filter(lambda lhePart: lhePart.pdgId == 25, lheParticles),
                key=lambda lheHiggs: get_p4(lheHiggs).E(
                ),  # sort by energy b/c pT is the same
                reverse=True)
            nofHiggs_lhe = len(higgses_lhe)

            if nofHiggs_lhe == 2:
                mHH_lhe, cosThetaStar_lhe, weightsBM_lhe, weightsScan_lhe = self.compute(
                    higgses_lhe)

                if self.use_gen:
                    assert (len(weightsBM_gen) == len(weightsBM_lhe))
                    assert (len(weightsScan_gen) == len(weightsScan_lhe))
            else:
                print(
                    "Found an event that has not exactly two Higgs bosons at the LHE parton level"
                )

        if self.use_gen:
            self.out.fillBranch(self.mHH_genName, mHH_gen)
            self.out.fillBranch(self.cosThetaStar_genName, cosThetaStar_gen)
        if self.use_lhe:
            self.out.fillBranch(self.mHH_lheName, mHH_lhe)
            self.out.fillBranch(self.cosThetaStar_lheName, cosThetaStar_lhe)
        if self.compute_weights:
            self.out.fillBranch(self.nofWeightsBMName, len(weightsBM_gen))
            self.out.fillBranch(self.nofWeightsScanName, len(weightsScan_gen))
            if self.use_gen:
                self.out.fillBranch(self.weightBM_genName, weightsBM_gen)
                self.out.fillBranch(self.weightScan_genName, weightsScan_gen)
            if self.use_lhe:
                self.out.fillBranch(self.weightBM_lheName, weightsBM_lhe)
                self.out.fillBranch(self.weightScan_lheName, weightsScan_lhe)

        return True
コード例 #10
0
def main():
    model = NonResonantModel()
    # obtaining BSM/SM coeficients
    #dumb = model.ReadCoefficients("../data/coefficientsByBin_A1A3A7.txt")
    #dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M.txt")
    dumb = model.ReadCoefficients(
        "../data/coefficientsByBin_extended_3M_costHHSim_19-4.txt")
    # We sum SM + box + the benchmarks from 2-13
    # read the 2D histo referent to the sum of events
    """
  fileHH=ROOT.TFile("../../../Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV.root")
  sumJHEPAnalyticalBin = fileHH.Get("H1bin2")
  SMAnalyticalBin = fileHH.Get("H0bin2")
  """
    fileHH = ROOT.TFile(
        "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root"
    )  #Distros_5p_SM3M_sumBenchJHEP_13TeV.root") #Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root") #
    #fileHH=ROOT.TFile("../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root")
    #sumJHEPAnalyticalBin = fileHH.Get("H1bin3")
    histfile = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root"  #Distros_5p_SM3M_sumBenchJHEP_13TeV.root" # #Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
    #histfile = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
    histtitle = "H1bin4"
    sumJHEPAnalyticalBin = fileHH.Get(histtitle)
    SMAnalyticalBin = fileHH.Get("H0bin4")

    #fileHHname = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
    calcSumOfWeights = model.getNormalization(
        kl, kt, c2, cg, c2g, histfile,
        histtitle)  # this input is flexible, tatabb may have only the SM
    #print ("normalization is: ",calcSumOfWeights)
    #xaxis = sumJHEPAnalyticalBin.GetXaxis()
    #yaxis = sumJHEPAnalyticalBin.GetYaxis()
    #print "Sum hist ",sumJHEPAnalyticalBin.GetNbinsX(),sumJHEPAnalyticalBin.GetNbinsY(),sumJHEPAnalyticalBin.Integral(),sumJHEPAnalyticalBin.GetXaxis().GetBinLowEdge(1),sumJHEPAnalyticalBin.GetXaxis().GetBinUpEdge(xaxis.GetNbins())
    #print SMAnalyticalBin.GetBinContent(4,4)
    # now loop over events, calculate weights using the coeffitients and  plot histograms
    # events to reweights, in text format (for testing only)
    pathBenchEvents = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/"  # events to reweight
    # declare the histograms
    CalcMhh = np.zeros((1200000))
    CalcCost = np.zeros((1200000))
    CalcPtH = np.zeros((1200000))
    CalcPtHgg = np.zeros((1200000))
    CalcPtHH = np.zeros((1200000))
    CalcWeight = np.zeros((1200000))
    CalcMhhReco = np.zeros((1200000))
    CalcMXReco = np.zeros((1200000))
    ##########################################
    # initialize tables of coefficients by bins
    # calculate mhh and cost* and find the bin
    # initialize events reading
    countline = 0
    countevent = 0
    counteventSM = 0
    # read events as text files for events to test
    # particuliarity of the text file with events = each 2 lines are one event there
    # save the information of the two Higgses
    Px = np.zeros((2))
    Py = np.zeros((2))
    Pz = np.zeros((2))
    En = np.zeros((2))
    for sam in range(1, 13):  # read events from the list of 12 benchmarks
        filne = pathBenchEvents + "GF_HH_" + str(
            sam
        ) + ".lhe.decayed"  # 0 is SM = here it does not enter in the events to be reweighted in this version
        f = open(filne, 'r+')
        lines = f.readlines()  # get all lines as a list (array)
        countline = 0  # particuliarity of the text file with events = each 2 lines are one event there
        for line in lines:
            model.ReadLine(line, countline, Px, Py, Pz, En)
            #print countline
            countline += 1
            mhhcost = [0, 0, 0,
                       0]  # to store [mhh , cost,ptH , ptHH] of that event
            if countline == 2:  # if read 2 lines
                model.CalculateMhhCost(mhhcost, countline, Px, Py, Pz,
                                       En)  # ==> adapt to your input
                bmhh = sumJHEPAnalyticalBin.GetXaxis().FindBin(mhhcost[0])
                bcost = sumJHEPAnalyticalBin.GetYaxis().FindBin(abs(
                    mhhcost[1]))
                #print (mhhcost[1],bcost)
                effSumV0 = sumJHEPAnalyticalBin.GetBinContent(
                    bmhh, bcost
                )  # quantity of simulated events in that bin (without cuts)
                #weight = model.getScaleFactor(mhhcost,kl, kt,0,model.effSM,model.effSum,model.MHH,model.COSTS,model.A1,model.A3,model.A7,0)
                #print mhhcost[1],bcost
                #print effSumV0
                weight = model.getScaleFactor(mhhcost[0], mhhcost[1], kl, kt,
                                              c2, cg, c2g, effSumV0,
                                              calcSumOfWeights)
                countline = 0
                #############################################
                # fill histograms
                #############################################
                if weight > 0:
                    #print countevent
                    CalcMhh[countevent] = float(mhhcost[0])
                    CalcCost[countevent] = float(mhhcost[1])
                    CalcPtH[countevent] = float(mhhcost[2])
                    CalcPtHH[countevent] = float(mhhcost[3])
                    CalcWeight[countevent] = weight
                    countevent += 1
                #else : print ("neg weight ",weight,mhhcost[0],mhhcost[1],bmhh,bcost,kl, kt,c2,cg,c2g,effSumV0,calcSumOfWeights)
        f.close()
    print "plotted hostogram reweighted from ", countevent, " events, ", float(
        100 * (1200000 - countevent) /
        1200000), " % of the events was lost in empty bins in SM simulation"
    print kl, kt, c2, cg, c2g, "Sum of weights:", CalcWeight.sum(
    ), " correction ", calcSumOfWeights
    ############################################################################################################################
    # Draw test histos
    ###############################################
    drawtest = -1
    nevtest = 50000
    #if kl == 1 and kt == 1 and c2 ==0 and cg == 0 and c2g ==0 :
    #   filne = pathBenchEvents+"GF_HH_0.lhe.decayed"    # 0 is SM
    #   nevtest = 100000
    #   drawtest = 1
    # BSM events
    pathBSMtest = "/afs/cern.ch/work/a/acarvalh/generateHH/asciiHH_tofit/GF_HH_toRecursive/"  # events of file to superimpose a test
    # see the translation of coefficients for this last on: If you make this script smarter (to only read files we ask to test) you can implement more
    # https://github.com/acarvalh/generateHH/blob/master/fit_GF_HH_lhe/tableToFitA3andA7.txt
    if kl == -10 and kt == 0.5 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_42.lhe.decayed"
    if kl == 0.0001 and kt == 2.25 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_9.lhe.decayed"
    if kl == 0.0001 and kt == 1.0 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_4.lhe.decayed"
    if kl == 2.5 and kt == 1.0 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_60.lhe.decayed"
    if kl == -15 and kt == 0.5 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_40.lhe.decayed"
    if kl == 5 and kt == 1.5 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_74.lhe.decayed"
    if kl == 7.5 and kt == 2.0 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_88.lhe.decayed"
    if kl == 0.0001 and kt == 0.0001 and c2 == -3.0 and cg == 0.0 and c2g == -1.5:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_281.lhe.decayed"
    if kl == -10 and kt == 0.0 and c2 == 1.0 and cg == 1.0 and c2g == 1.0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_280.lhe.decayed"
    #########################################################
    klJHEP = [
        1.0, 7.5, 1.0, 1.0, -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0
    ]
    ktJHEP = [1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0]
    c2JHEP = [
        0.0, -1.0, 0.5, -1.5, -3.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 1.0
    ]
    cgJHEP = [
        0.0, 0.0, 0.6, 0.0, 0.0, 0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0
    ]
    c2gJHEP = [
        0.0, 0.0, 1.0, -0.8, 0.0, -1.0, -0.2, -0.2, 1.0, 0.6, 0.0, -1.0, 0.0
    ]
    # python recastHH.py --kl 7.5 --kt 1 --c2 -1
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.5 --cg -0.8 --c2g 0.6
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 -1.5 --cg 0.0 --c2g -0.8
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.0 --cg 0.8 --c2g -1.0
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 1.0 --cg -0.6 --c2g 0.6
    for sam in range(0, 13):
        #print (sam, ktJHEP[sam] , kt , klJHEP[sam] , c2 ,c2JHEP[sam] , cg , cgJHEP[sam] , c2g , c2gJHEP[sam])
        if kl == klJHEP[sam] and kt == ktJHEP[sam] and c2 == c2JHEP[
                sam] and cg == cgJHEP[sam] and c2g == c2gJHEP[sam]:
            print sam
            filne = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_" + str(
                sam) + ".lhe.decayed"
            nevtest = 100000
            drawtest = sam

    ############################################################################################################################
    CalcMhhTest = np.zeros((nevtest))
    CalcCostTest = np.zeros((nevtest))
    CalcPtHTest = np.zeros((nevtest))
    CalcPtHHTest = np.zeros((nevtest))
    CalcPtHggTest = np.zeros((nevtest))
    CalcMhhRecoTest = np.zeros((nevtest))
    CalcMXRecoTest = np.zeros((nevtest))
    if options.doPlot and drawtest > 0:
        print "draw plain histogram to test"
        model.LoadTestEvents(CalcMhhTest, CalcCostTest, CalcPtHTest,
                             CalcPtHHTest, filne)
    model.plotting(kl, kt, c2, cg, c2g, CalcMhh, CalcCost, CalcPtHgg, CalcPtHH,
                   CalcMhhReco, CalcMXReco, CalcWeight, CalcMhhTest,
                   CalcCostTest, CalcPtHggTest, CalcPtHHTest, CalcMhhRecoTest,
                   CalcMXRecoTest, drawtest)
コード例 #11
0
def main():
  model = NonResonantModel()
  # obtaining BSM/SM coeficients
  #dumb = model.ReadCoefficients("../data/coefficientsByBin_A1A3A7.txt") 
  #dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M.txt") 
  dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M_costHHSim_19-4.txt") 
  # We sum SM + box + the benchmarks from 2-13 
  # read the 2D histo referent to the sum of events
  """
  fileHH=ROOT.TFile("../../../Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV.root")
  sumJHEPAnalyticalBin = fileHH.Get("H1bin2")
  SMAnalyticalBin = fileHH.Get("H0bin2")
  """
  fileHH=ROOT.TFile("../../../Analysis/Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root") #Distros_5p_SM3M_sumBenchJHEP_13TeV.root") #Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root") #
  #fileHH=ROOT.TFile("../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root") 
  #sumJHEPAnalyticalBin = fileHH.Get("H1bin3")
  histfile = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV_19-4.root" #Distros_5p_SM3M_sumBenchJHEP_13TeV.root" # #Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
  #histfile = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
  histtitle = "H1bin4"
  sumJHEPAnalyticalBin = fileHH.Get(histtitle)
  SMAnalyticalBin = fileHH.Get("H0bin4")
  
  #fileHHname = "../../../Analysis/Support/NonResonant/Distros_5p_SM3M_rebin_sumBenchJHEP_5D_13TeV.root"
  calcSumOfWeights = model.getNormalization(kl, kt,c2,cg,c2g,histfile,histtitle)  # this input is flexible, tatabb may have only the SM
  #print ("normalization is: ",calcSumOfWeights)
  #xaxis = sumJHEPAnalyticalBin.GetXaxis()
  #yaxis = sumJHEPAnalyticalBin.GetYaxis()
  #print "Sum hist ",sumJHEPAnalyticalBin.GetNbinsX(),sumJHEPAnalyticalBin.GetNbinsY(),sumJHEPAnalyticalBin.Integral(),sumJHEPAnalyticalBin.GetXaxis().GetBinLowEdge(1),sumJHEPAnalyticalBin.GetXaxis().GetBinUpEdge(xaxis.GetNbins())
  #print SMAnalyticalBin.GetBinContent(4,4)
  # now loop over events, calculate weights using the coeffitients and  plot histograms
  # events to reweights, in text format (for testing only)
  pathBenchEvents="/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/" # events to reweight
  # declare the histograms 
  CalcMhh = np.zeros((1200000))
  CalcCost = np.zeros((1200000))
  CalcPtH = np.zeros((1200000))
  CalcPtHgg = np.zeros((1200000))
  CalcPtHH = np.zeros((1200000))
  CalcWeight = np.zeros((1200000))
  CalcMhhReco = np.zeros((1200000))
  CalcMXReco = np.zeros((1200000))
  ##########################################
  # initialize tables of coefficients by bins
  # calculate mhh and cost* and find the bin
  # initialize events reading 
  countline=0
  countevent=0
  counteventSM=0
  # read events as text files for events to test 
  # particuliarity of the text file with events = each 2 lines are one event there
  # save the information of the two Higgses
  Px = np.zeros((2)) 
  Py = np.zeros((2)) 
  Pz = np.zeros((2)) 
  En = np.zeros((2))  
  for sam in  range(1,13): # read events from the list of 12 benchmarks
       filne = pathBenchEvents+"GF_HH_"+str(sam)+".lhe.decayed"    # 0 is SM = here it does not enter in the events to be reweighted in this version
       f = open(filne, 'r+')
       lines = f.readlines() # get all lines as a list (array)
       countline = 0 # particuliarity of the text file with events = each 2 lines are one event there
       for line in  lines:
          model.ReadLine(line, countline,Px,Py,Pz,En)
          #print countline
          countline+=1
          mhhcost= [0,0,0,0] # to store [mhh , cost,ptH , ptHH] of that event
          if countline==2 : # if read 2 lines 
            model.CalculateMhhCost(mhhcost,countline,Px,Py,Pz,En) # ==> adapt to your input 
            bmhh = sumJHEPAnalyticalBin.GetXaxis().FindBin(mhhcost[0])
            bcost = sumJHEPAnalyticalBin.GetYaxis().FindBin(abs(mhhcost[1]))
            #print (mhhcost[1],bcost)
            effSumV0 = sumJHEPAnalyticalBin.GetBinContent(bmhh,bcost)  # quantity of simulated events in that bin (without cuts)
            #weight = model.getScaleFactor(mhhcost,kl, kt,0,model.effSM,model.effSum,model.MHH,model.COSTS,model.A1,model.A3,model.A7,0)  
            #print mhhcost[1],bcost
            #print effSumV0
            weight = model.getScaleFactor(mhhcost[0],mhhcost[1],kl, kt,c2,cg,c2g, effSumV0,calcSumOfWeights) 
            countline=0
            #############################################
            # fill histograms
            #############################################
            if weight > 0: 
               #print countevent
               CalcMhh[countevent] = float(mhhcost[0]) 
               CalcCost[countevent] = float(mhhcost[1]) 
               CalcPtH[countevent] = float(mhhcost[2]) 
               CalcPtHH[countevent] = float(mhhcost[3]) 
               CalcWeight[countevent] = weight 
               countevent+=1
            #else : print ("neg weight ",weight,mhhcost[0],mhhcost[1],bmhh,bcost,kl, kt,c2,cg,c2g,effSumV0,calcSumOfWeights)
       f.close()
  print "plotted hostogram reweighted from ",countevent," events, ", float(100*(1200000-countevent)/1200000)," % of the events was lost in empty bins in SM simulation"
  print kl, kt,c2,cg,c2g, "Sum of weights:", CalcWeight.sum()," correction ",calcSumOfWeights
  ############################################################################################################################
  # Draw test histos
  ###############################################
  drawtest =-1 
  nevtest=50000
  #if kl == 1 and kt == 1 and c2 ==0 and cg == 0 and c2g ==0 : 
  #   filne = pathBenchEvents+"GF_HH_0.lhe.decayed"    # 0 is SM
  #   nevtest = 100000
  #   drawtest = 1 
  # BSM events
  pathBSMtest="/afs/cern.ch/work/a/acarvalh/generateHH/asciiHH_tofit/GF_HH_toRecursive/" # events of file to superimpose a test
  # see the translation of coefficients for this last on: If you make this script smarter (to only read files we ask to test) you can implement more
  # https://github.com/acarvalh/generateHH/blob/master/fit_GF_HH_lhe/tableToFitA3andA7.txt
  if kl == -10 and kt == 0.5 and c2 ==0 and cg == 0 and c2g ==0 :
     drawtest =1
     filne = pathBSMtest+"GF_HH_42.lhe.decayed"
  if kl == 0.0001 and kt == 2.25 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_9.lhe.decayed"
  if kl == 0.0001 and kt == 1.0 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_4.lhe.decayed"
  if kl == 2.5 and kt == 1.0 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_60.lhe.decayed"
  if kl == -15 and kt == 0.5 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_40.lhe.decayed"
  if kl == 5 and kt == 1.5 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_74.lhe.decayed"
  if kl == 7.5 and kt == 2.0 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_88.lhe.decayed"
  if kl == 0.0001 and kt == 0.0001 and c2 ==-3.0 and cg == 0.0 and c2g ==-1.5  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_281.lhe.decayed"
  if kl == -10 and kt == 0.0 and c2 ==1.0 and cg == 1.0 and c2g ==1.0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_280.lhe.decayed"
  #########################################################
  klJHEP=[1.0, 7.5,  1.0,  1.0,  -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0]
  ktJHEP=[1.0, 1.0,  1.0,  1.0,  1.5,  1.0, 1.0, 1.0, 1.0,  1.0, 1.5,  1.0, 1.0]
  c2JHEP=[0.0, -1.0, 0.5, -1.5, -3.0,  0.0, 0.0, 0.0, 0.0,  1.0, -1.0, 0.0, 1.0]
  cgJHEP=[0.0, 0.0, 0.6,  0.0, 0.0,   0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0]
  c2gJHEP=[0.0, 0.0, 1.0, -0.8, 0.0, -1.0, -0.2,-0.2,  1.0,  0.6, 0.0, -1.0, 0.0]
  # python recastHH.py --kl 7.5 --kt 1 --c2 -1
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.5 --cg -0.8 --c2g 0.6
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 -1.5 --cg 0.0 --c2g -0.8
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.0 --cg 0.8 --c2g -1.0
  # python recastHH.py --kl 1.0 --kt 1.0 --c2 1.0 --cg -0.6 --c2g 0.6
  for sam in range(0,13):
    #print (sam, ktJHEP[sam] , kt , klJHEP[sam] , c2 ,c2JHEP[sam] , cg , cgJHEP[sam] , c2g , c2gJHEP[sam])
    if kl == klJHEP[sam] and kt == ktJHEP[sam] and c2 ==c2JHEP[sam] and cg == cgJHEP[sam] and c2g ==c2gJHEP[sam] : 
       print sam
       filne="/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_"+str(sam)+".lhe.decayed"
       nevtest=100000
       drawtest = sam 

  ############################################################################################################################
  CalcMhhTest = np.zeros((nevtest))
  CalcCostTest = np.zeros((nevtest))
  CalcPtHTest = np.zeros((nevtest))
  CalcPtHHTest = np.zeros((nevtest))
  CalcPtHggTest = np.zeros((nevtest))
  CalcMhhRecoTest = np.zeros((nevtest))
  CalcMXRecoTest = np.zeros((nevtest))
  if options.doPlot and drawtest >0 : 
     print "draw plain histogram to test"
     model.LoadTestEvents(CalcMhhTest,CalcCostTest,CalcPtHTest,CalcPtHHTest,filne)  
  model.plotting(kl,kt,c2,cg,c2g,CalcMhh,CalcCost,CalcPtHgg,CalcPtHH,CalcMhhReco,CalcMXReco,CalcWeight,CalcMhhTest,CalcCostTest,CalcPtHggTest,CalcPtHHTest,CalcMhhRecoTest,CalcMXRecoTest,drawtest)
コード例 #12
0
def main():
    #if 1 > 0 :
    # declare the 2D ===> should be global variable
    model = NonResonantModel()
    # obtaining BSM/SM coeficients
    #dumb = model.ReadCoefficients("../data/coefficientsByBin_A1A3A7.txt")
    dumb = model.ReadCoefficients(
        "../data/coefficientsByBin_extended_3M_costHHSim_19-4.txt")
    #dumb = model.ReadCoefficients("../data/coefficientsByBin_extended_3M.txt")
    counteventSM = 0
    sumWeight = 0
    # now loop over events, calculate weights using the coeffitients and  plot histograms
    # We sum SM + box + the benchmarks from 2-13
    # read the 2D histo referent to the sum of events
    #fileHH=ROOT.TFile("../../../Analysis/Support/NonResonant/Hist2DSum_V0_SM_box.root")
    #sumHAnalyticalBin = fileHH.Get("SumV0_AnalyticalBin")
    histfilename = "../../../Analysis/Support/NonResonant/HistSum2D_4b_rebin_SimCostHH_19-4.root"
    #histtitle= "SumV0_AnalyticalBinExt" #
    histtitle = "SumV0_AnalyticalBinExtSimCostHH"  #
    fileHH = ROOT.TFile(histfilename)
    sumHAnalyticalBin = fileHH.Get(histtitle)
    calcSumOfWeights = model.getNormalization(
        kl, kt, c2, cg, c2g, histfilename,
        histtitle)  # this input is flexible, tatabb may have only the SM
    # print "sum of weights calculated" , calcSumOfWeights
    # read the events
    pathBenchEvents = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/"  #"/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/" # events to reweight
    file = ROOT.TFile(pathBenchEvents + "events_SumV0.root")
    tree = file.Get("treeout")
    nev = tree.GetEntries()
    # declare the histograms
    CalcMhh = np.zeros((nev))
    CalcCost = np.zeros((nev))
    CalcPtH = np.zeros((nev))
    CalcPtHH = np.zeros((nev))
    CalcWeight = np.zeros((nev))

    CalcPtHgg = np.zeros((nev))
    CalcMhhReco = np.zeros((nev))
    CalcMXReco = np.zeros((nev))

    countevent = 0
    #for kll in range(-5,5) : model.getNormalization(kll, kt,sumHBenchBin)
    for iev in range(0, nev):
        tree.GetEntry(iev)
        mhh = tree.Genmhh
        cost = tree.GenHHCost

        mhhcost = [mhh, cost, 0, 0]  # to store [mhh , cost] of that event
        # find the Nevents from the sum of events on that bin
        bmhh = sumHAnalyticalBin.GetXaxis().FindBin(mhh)
        bcost = sumHAnalyticalBin.GetYaxis().FindBin(abs(cost))
        #print (tree.GenHHCost,cost,bcost)
        effSumV0 = sumHAnalyticalBin.GetBinContent(bmhh, abs(
            bcost))  # quantity of simulated events in that bin (without cuts)
        weight = model.getScaleFactor(
            mhh, cost, kl, kt, c2, cg, c2g, effSumV0, calcSumOfWeights
        )  # model.effSM,model.MHH,model.COSTS,model.A1,model.A3,model.A7, effSumV0)
        #############################################
        # fill histograms to test
        #############################################
        if weight > 0:
            #print countevent
            CalcMhh[countevent] = float(mhhcost[0])
            CalcCost[countevent] = float(abs(mhhcost[1]))
            CalcPtH[countevent] = float(mhhcost[2])
            CalcPtHH[countevent] = float(mhhcost[3])
            CalcWeight[countevent] = weight
            countevent += 1
            sumWeight += weight
    print "plotted histogram reweighted from ", countevent, " events, ", float(
        100 * (nev - countevent) /
        nev), " % of the events was lost in empty bins in SM simulation"
    print "sum of weights", sumWeight
    ############################################################################################################################
    # Draw test histos
    ###############################################
    drawtest = 0
    nevtest = 50000
    if kl == 1 and kt == 1 and c2 == 0 and cg == 0 and c2g == 0:
        filne = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_0.lhe.decayed"  # 0 is SM
        nevtest = 100000
        drawtest = 1
    # BSM events
    pathBSMtest = "/afs/cern.ch/work/a/acarvalh/generateHH/asciiHH_tofit/GF_HH_toRecursive/"  # events of file to superimpose a test
    # see the translation of coefficients for this last on: If you make this script smarter (to only read files we ask to test) you can implement more
    # https://github.com/acarvalh/generateHH/blob/master/fit_GF_HH_lhe/tableToFitA3andA7.txt
    if kl == -10 and kt == 0.5 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_42.lhe.decayed"
    if kl == 0.0001 and kt == 2.25 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_9.lhe.decayed"
    if kl == 2.5 and kt == 1.0 and c2 == 0 and cg == 0 and c2g == 0:
        drawtest = 1
        filne = pathBSMtest + "GF_HH_60.lhe.decayed"
    klJHEP = [
        1.0, 7.5, 1.0, 1.0, -3.5, 1.0, 2.4, 5.0, 15.0, 1.0, 10.0, 2.4, 15.0
    ]
    ktJHEP = [1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 1.0, 1.0]
    c2JHEP = [
        0.0, -1.0, 0.5, -1.5, -3.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 1.0
    ]
    cgJHEP = [
        0.0, 0.0, 0.6, 0.0, 0.0, 0.8, 0.2, 0.2, -1.0, -0.6, 0.0, 1.0, 0.0
    ]
    c2gJHEP = [
        0.0, 0.0, 1.0, -0.8, 0.0, -1.0, -0.2, -0.2, 1.0, 0.6, 0.0, -1.0, 0.0
    ]
    # python recastHH.py --kl 7.5 --kt 1 --c2 -1
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.5 --cg -0.8 --c2g 0.6
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 -1.5 --cg 0.0 --c2g -0.8
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 0.0 --cg 0.8 --c2g -1.0
    # python recastHH.py --kl 1.0 --kt 1.0 --c2 1.0 --cg -0.6 --c2g 0.6
    for sam in range(0, 13):
        #print (sam, ktJHEP[sam] , kt , klJHEP[sam] , c2 ,c2JHEP[sam] , cg , cgJHEP[sam] , c2g , c2gJHEP[sam])
        if kl == klJHEP[sam] and kt == ktJHEP[sam] and c2 == c2JHEP[
                sam] and cg == cgJHEP[sam] and c2g == c2gJHEP[sam]:
            print sam
            filne = "/eos/user/a/acarvalh/asciiHH_tofit/GF_HH_BSM/GF_HH_" + str(
                sam) + ".lhe.decayed"
            nevtest = 100000
            drawtest = sam
    ############################################################################################################################
    CalcMhhTest = np.zeros((nevtest))
    CalcCostTest = np.zeros((nevtest))
    CalcPtHTest = np.zeros((nevtest))
    CalcPtHHTest = np.zeros((nevtest))

    CalcPtHggTest = np.zeros((nevtest))
    CalcMhhRecoTest = np.zeros((nevtest))
    CalcMXRecoTest = np.zeros((nevtest))
    if options.doPlot:
        print "draw plain histogram to test"
        model.LoadTestEvents(CalcMhhTest, CalcCostTest, CalcPtHTest,
                             CalcPtHHTest, filne)
        model.plotting(kl, kt, c2, cg, c2g, CalcMhh, CalcCost, CalcPtHgg,
                       CalcPtHH, CalcMhhReco, CalcMXReco, CalcWeight,
                       CalcMhhTest, CalcCostTest, CalcPtHggTest, CalcPtHHTest,
                       CalcMhhRecoTest, CalcMXRecoTest, drawtest)
コード例 #13
0
def main():
  model = NonResonantModel()
  # obtaining BSM/SM coeficients
  dumb = model.ReadCoefficients("../data/coefficientsByBin_klkt.txt",model.effSM,model.effSum,model.MHH,model.COSTS,model.A1,model.A3,model.A7) 
  # We sum SM + box + the benchmarks from 2-13 
  # read the 2D histo referent to the sum of events
  fileHH=ROOT.TFile("../../Support/NonResonant/Distros_5p_SM3M_sumBenchJHEP_13TeV.root")
  sumJHEPAnalyticalBin = fileHH.Get("H1bin2")
  SMAnalyticalBin = fileHH.Get("H0bin2")
  xaxis = sumJHEPAnalyticalBin.GetXaxis()
  yaxis = sumJHEPAnalyticalBin.GetYaxis()
  print "Sum hist ",sumJHEPAnalyticalBin.GetNbinsX(),sumJHEPAnalyticalBin.GetNbinsY(),sumJHEPAnalyticalBin.Integral(),sumJHEPAnalyticalBin.GetXaxis().GetBinLowEdge(1),sumJHEPAnalyticalBin.GetXaxis().GetBinUpEdge(xaxis.GetNbins())
  #print SMAnalyticalBin.GetBinContent(4,4)
  # now loop over events, calculate weights using the coeffitients and  plot histograms
  # events to reweights, in text format (for testing only)
  pathBenchEvents="/afs/cern.ch/work/a/acarvalh/public/toAnamika/GF_HH_BSM/" # events to reweight
  # declare the histograms 
  CalcMhh = np.zeros((1200000))
  CalcCost = np.zeros((1200000))
  CalcWeight = np.zeros((1200000))
  ##########################################
  # initialize tables of coefficients by bins
  # calculate mhh and cost* and find the bin
  # initialize events reading 
  countline=0
  countevent=0
  counteventSM=0
  # read events as text files for events to test 
  # particuliarity of the text file with events = each 2 lines are one event there
  # save the information of the two Higgses
  Px = np.zeros((2)) 
  Py = np.zeros((2)) 
  Pz = np.zeros((2)) 
  En = np.zeros((2))  
  for sam in  range(1,13): # read events from the list of 12 benchmarks
       filne = pathBenchEvents+"GF_HH_"+str(sam)+".lhe.decayed"    # 0 is SM = here it does not enter in the events to be reweighted in this version
       f = open(filne, 'r+')
       lines = f.readlines() # get all lines as a list (array)
       countline = 0 # particuliarity of the text file with events = each 2 lines are one event there
       for line in  lines:
          model.ReadLine(line, countline,Px,Py,Pz,En)
          #print countline
          countline+=1
          mhhcost= [0,0] # to store [mhh , cost] of that event
          if countline==2 : # if read 2 lines 
            model.CalculateMhhCost(mhhcost,countline,Px,Py,Pz,En) # ==> adapt to your input 
            bmhh = sumJHEPAnalyticalBin.GetXaxis().FindBin(mhhcost[0])
            bcost = sumJHEPAnalyticalBin.GetYaxis().FindBin(mhhcost[1])
            effSumV0 = sumJHEPAnalyticalBin.GetBinContent(bmhh,bcost)  # quantity of simulated events in that bin (without cuts)
            #weight = model.getScaleFactor(mhhcost,kl, kt,0,model.effSM,model.effSum,model.MHH,model.COSTS,model.A1,model.A3,model.A7,0)  
            #print mhhcost[1],bcost
            #print effSumV0
            weight = model.getScaleFactor(mhhcost,kl, kt,model.effSM,model.MHH,model.COSTS,model.A1,model.A3,model.A7,effSumV0)  
            countline=0
            #############################################
            # fill histograms
            #############################################
            if weight > 0: 
               #print countevent
               CalcMhh[countevent] = float(mhhcost[0]) 
               CalcCost[countevent] = float(mhhcost[1]) 
               CalcWeight[countevent] = weight 
               countevent+=1
       f.close()
  print "plotted hostogram reweighted from ",countevent," events, ", float(100*(1200000-countevent)/1200000)," % of the events was lost in empty bins in SM simulation"
  ############################################################################################################################
  # Draw test histos
  ###############################################
  drawtest =0 
  nevtest=50000
  if kl == 1 and kt == 1 and c2 ==0 and cg == 0 and c2g ==0 : 
     filne = pathBenchEvents+"GF_HH_0.lhe.decayed"    # 0 is SM
     nevtest = 100000
     drawtest = 1 
  # BSM events
  pathBSMtest="/afs/cern.ch/work/a/acarvalh/public/toAnamika/GF_HH_toRecursive/" # events of file to superimpose a test
  # see the translation of coefficients for this last on: If you make this script smarter (to only read files we ask to test) you can implement more
  # https://github.com/acarvalh/generateHH/blob/master/fit_GF_HH_lhe/tableToFitA3andA7.txt
  if kl == -10 and kt == 0.5 and c2 ==0 and cg == 0 and c2g ==0 :
     drawtest =1
     filne = pathBSMtest+"GF_HH_42.lhe.decayed"
  if kl == 0.0001 and kt == 2.25 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_9.lhe.decayed"
  if kl == 2.5 and kt == 1.0 and c2 ==0 and cg == 0 and c2g ==0  :
     drawtest =1
     filne = pathBSMtest+"GF_HH_60.lhe.decayed"
  ############################################################################################################################
  CalcMhhTest = np.zeros((nevtest))
  CalcCostTest = np.zeros((nevtest))
  if drawtest ==1 :
     print "draw plain histogram to test"
     model.LoadTestEvents(CalcMhhTest,CalcCostTest,filne)  
  model.plotting(kl,kt,CalcMhh,CalcCost,CalcWeight,CalcMhhTest,CalcCostTest,drawtest)
コード例 #14
0
ファイル: clone_aabb.py プロジェクト: cms-hh/HHStatAnalysis
import shutil,subprocess
from HHStatAnalysis.AnalyticalModels.NonResonantModel import NonResonantModel

# ROOT imports
import ROOT
from ROOT import TChain, TH1F, TFile, vector, gROOT, TTree

##################
# read the histos tree and contruct the tree of the relevant variables 
LM=1
if LM == 0 : path = "/afs/cern.ch/user/a/andrey/public/HH/LT-Jan25-APZ_HighMass/" 
if LM == 1 : path = "/afs/cern.ch/user/a/andrey/public/HH/LT-Jan25-APZ_LowMass/" 
if histdone==0 : path = "/afs/cern.ch/user/a/andrey/public/HH/GenTrees_for_Xandra/" 
outpath="/afs/cern.ch/user/a/acarvalh/public/toAABB/"
data="../../../HHStatAnalysis/AnalyticalModels/data/"
model = NonResonantModel()
# obtaining BSM/SM coeficients
dumb = model.ReadCoefficients("../../../HHStatAnalysis/AnalyticalModels/data/coefficientsByBin_klkt.txt")  


if LM == 0 : fileoutput = "events_SumV0_afterBaseline_HM.root"
if LM == 1 : fileoutput = "events_SumV0_afterBaseline_LM.root"

files = []
endfile = "_13TeV-madgraph.root"

if histdone==1 : 
  files.append("LT_output_GluGluToHHTo2B2G_node_SM")
  files.append("LT_output_GluGluToHHTo2B2G_node_box")
  for ifile in range(2,14) : files.append("LT_output_GluGluToHHTo2B2G_node_"+str(ifile))