# samples.append(sample) # samples[-1].name+='_%i'%i_param # print param # samples[-1].style = styles.lineStyle( param['color'] ) # samples[-1].texName = param['legendText'] # #samples[-1].ttreeFormula = ROOT.TTreeFormula("weightstring_%i"%i_param, w.get_weight_string(**param['WC']), samples[-1].chain ) # samples[-1].paramWeightFunc = w.get_weight_func(**param['WC']) #def getWeightFunc(sample): # formula = sample.ttreeFormula # def rw(event, sample): # return formula.EvalInstance() # return rw stack = Stack(*[ [ sample ] for param in params ] ) weight= [ [ w.get_weight_func(**param['WC']) ] for param in params ] #print weight ## ## Text on the plots ## def drawObjects( hasData = False ): tex = ROOT.TLatex() tex.SetNDC() tex.SetTextSize(0.04) tex.SetTextAlign(11) # align right lines = [ (0.15, 0.95, 'CMS Preliminary' if hasData else "Robert\'s CMS Simulation"), #(0.45, 0.95, 'L=%3.1f fb{}^{-1} (13 TeV) Scale %3.2f'% ( lumi_scale, dataMCScale ) ) if plotData else (0.45, 0.95, 'L=%3.1f fb{}^{-1} (13 TeV)' % lumi_scale) ] return [tex.DrawLatex(*l) for l in lines]
sample.reduceFiles( to = 10 ) output_dir = os.path.join(tmp_directory, args.version) if not os.path.exists(output_dir): os.makedirs( output_dir ) # lumi lumi = 150 # Polynomial parametrization w = WeightInfo(sample.reweight_pkl) w.set_order(2) # function that evaluates the weight of the SM hypothesis sm_weight = w.get_weight_func() # function that evaluates the weight of the BSM hypothesis bsm_weight = w.get_weight_func(ctGI=10) selectionString = "Sum$(genLep_pt>10&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)==3&&Sum$(genLep_pt>20&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)>=2&&Sum$(genLep_pt>40&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)>=1&&abs(genZ_mass-91.2)<=10&&Sum$(genJet_pt>30&&abs(genJet_eta)<2.4)>=3&&Sum$(genJet_pt>30&&genJet_matchBParton>=1&&abs(genJet_eta)<2.4)>=1&&genZ_pt>=0" sample.setSelectionString( selectionString ) # Define variables file_read_variables = [ "genZ_pt/F", "genZ_eta/F", "genZ_phi/F", "genZ_mass/F", "genZ_cosThetaStar/F", "ref_lumiweight1fb/F" ] read_variables = map( TreeVariable.fromString, file_read_variables) read_variables.append( VectorTreeVariable.fromString('p[C/F]', nMax=2000) ) training_variables = { 'genZ_pt/F' : lambda event: event.genZ_pt, 'genZ_cosThetaStar/F' : lambda event: event.genZ_cosThetaStar }
# Root_numpy from root_numpy import root2array # make small sample.reduceFiles(to=1) # lumi lumi = 150 # Polynomial parametrization w = WeightInfo(sample.reweight_pkl) w.set_order(2) # function that evaluates the weight of the SM hypothesis sm_weight = w.get_weight_func() # function that evaluates the weight of the BSM hypothesis bsm_weight = w.get_weight_func(ctZ=4) selectionString = "Sum$(genLep_pt>10&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)==3&&Sum$(genLep_pt>20&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)>=2&&Sum$(genLep_pt>40&&(abs(genLep_pdgId)==11||abs(genLep_pdgId)==13)&&abs(genLep_eta)<2.5)>=1&&abs(genZ_mass-91.2)<=10&&Sum$(genJet_pt>30&&abs(genJet_eta)<2.4)>=3&&Sum$(genJet_pt>30&&genJet_matchBParton>=1&&abs(genJet_eta)<2.4)>=1&&genZ_pt>=0" print sample.files X = root2array(sample.files, branches=[ "genZ_pt", "genZ_eta", "genZ_phi", "genZ_mass", "genZ_cosThetaStar", "ref_lumiweight1fb" ], selection=selectionString) print X