Wjetstree.Add( bkgDir + "WJetsToLNu_400HTInf_v2_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") Zjetstree = TChain("RA2TreeFiller/AnalysisTree") Zjetstree.Add( bkgDir + "ZJetsToNuNu_400HTinf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") TTjetstree = TChain("RA2TreeFiller/AnalysisTree") TTjetstree.Add( bkgDir + "TTJets_SemiLeptMGDecays_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") referenceCardSMJ = datacard( SMJbins, [sampleName], ["QCD500", "QCD1000", "ZinvJets", "WlvJets", "TTsemiLeptJets"]) referenceCard = datacard( RA2bins, [sampleName], ["QCD500", "QCD1000", "ZinvJets", "WlvJets", "TTsemiLeptJets"]) #print "QCD500" #computeYields( QCD500tree , referenceCard.binning , referenceCard.bkgYields["QCD500"] , 5.582 ) QCD500yields = [0] * referenceCard.binning.nBins QCD500yieldsSMJ = [0] * referenceCardSMJ.binning.nBins QCD500proc = Process(target=computeYields, args=(QCD500tree, referenceCard.binning, QCD500yields, 5.582)) QCD500procSMJ = Process(target=computeYields, args=(QCD500tree, referenceCardSMJ.binning, QCD500yieldsSMJ, 5.582))
######################################################################################################### if __name__ == '__main__': binning = options.binning theBins = GetBinning(binning) signalmodels = [ 'SMStttt1500', 'SMStttt1200', 'SMSbbbb1500', 'SMSbbbb1000', 'SMSqqqq1400', 'SMSqqqq1000' ] # --------------------------------------------------- ## Define cards to build myDatacard = [] for signal in signalmodels: myDatacard.append( datacard(theBins, [signal], ["QCD", "Zinv", "WjetTT"])) # --------------------------------------------------- ## Define the files inputDir = "./" accessProtocol = "root://cmsxrootd-site.fnal.gov//store/user/" fileDir = "/uscms_data/d2/ntran/physics/SUSY/Run2/statInterp/project/CMSSW_7_1_5/src/CombineTools/macros/LatestSynchFiles/" treeName = 'TreeMaker2/PreSelection' SignalTrees = [] for i in range(len(signalmodels)): tmptree = TChain(treeName) tmptree.Add(fileDir + signalmodels[i] + ".root") SignalTrees.append(tmptree)
def buildCards(sampleName = "T1qqqq_HV" , massMom = 1000 , massDau = 25 , binning = "Classic" ) : #myDatacard = datacard( njetBins , ["T1tttt"] , [ "QCD500" , "QCD1000" , "ZinvJets" , "WlvJets" , "TTsemiLeptJets" ] ) if binning == "SMJ" : myDatacard = datacard( SMJbins , [sampleName] , [ "QCD500" , "QCD1000" , "ZinvJets" , "WlvJets" , "TTsemiLeptJets" ] ) elif binning == "Classic" : myDatacard = datacard( RA2bins , [sampleName] , [ "QCD500" , "QCD1000" , "ZinvJets" , "WlvJets" , "TTsemiLeptJets" ] ) elif binning == "extSMJ" : myDatacard = datacard( extRA2bins , [sampleName] , [ "QCD500" , "QCD1000" , "ZinvJets" , "WlvJets" , "TTsemiLeptJets" ] ) else : raise NameError(binning) return inputDir = "./" accessProtocol = "root://cmsxrootd-site.fnal.gov//store/user/" bkgDir = "awhitbe1/SuSySubstructureAnalysisNtuples_V8/" ### background trees QCD500tree = TChain("RA2TreeFiller/AnalysisTree") QCD500tree.Add( accessProtocol + bkgDir + "QCD_500HT1000_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root" ) #print QCD500tree.GetEntries() QCD1000tree = TChain( "RA2TreeFiller/AnalysisTree" ) QCD1000tree.Add( accessProtocol + bkgDir + "QCD_1000HTinf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root" ) #print QCD1000tree.GetEntries() Wjetstree = TChain( "RA2TreeFiller/AnalysisTree" ) Wjetstree.Add( accessProtocol + bkgDir + "WJetsToLNu_400HTInf_v2_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root" ) #print Wjetstree.GetEntries() Zjetstree = TChain( "RA2TreeFiller/AnalysisTree" ) Zjetstree.Add( accessProtocol + bkgDir + "ZJetsToNuNu_400HTinf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root" ) #print Zjetstree.GetEntries() TTjetstree = TChain( "RA2TreeFiller/AnalysisTree" ) TTjetstree.Add( accessProtocol + bkgDir + "TTJets_SemiLeptMGDecays_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root" ) #print TTjetstree.GetEntries() #### load signal files fileNames = [] sigDir = "awhitbe1/SuSySubstructureAnalysisNtuples_V8/" ### signal files for T1tttt trees #fileNames.append(accessProtocol + "{0}/T1qqqq_HiddenValley_SumJetMass_AnalysisTree.root".format( sigDir ) ) fileNames.append(accessProtocol + "{0}/SMS_T1tttt_mGo1100_mLSP25_ALL_SumJetMass_AnalysisTree.root".format( sigDir ) ) treeName = "TreeFiller/AnalysisTree" #treeName = "RA2PreSelection" #print "QCD500" computeYields( QCD500tree , myDatacard.binning , myDatacard.bkgYields["QCD500"] , 5.7398 ) #print "QCD1000" computeYields( QCD1000tree , myDatacard.binning , myDatacard.bkgYields["QCD1000"] , 0.3179 ) #print "ZinvJets" computeYields( Zjetstree , myDatacard.binning , myDatacard.bkgYields["ZinvJets"] , 0.1237 ) #print "WlvJets" computeYields( Wjetstree , myDatacard.binning , myDatacard.bkgYields["WlvJets"] , 0.1222 ) #print "TTsemiLeptJets" computeYields( TTjetstree , myDatacard.binning , myDatacard.bkgYields["TTsemiLeptJets"] , 0.0816 ) sigTree = TChain(treeName) for fileName in fileNames : sigTree.Add(fileName) if sigTree == None or sigTree.GetEntries() <= 0 : #raise InputError("Tree not found! Skipping this point") return print "Signal" computeYields( sigTree , myDatacard.binning , myDatacard.sigYields[sampleName] , xsec[int(massMom)]*19500./sigTree.GetEntries() ) print myDatacard.binning.nBins for i in range( myDatacard.binning.nBins ) : if binning == "SMJ" : myDatacard.printDatacard("{3}_mGo{1}_mLSP{2}_datacard_TEST_SMJ_bin{0}.txt".format( i , massMom , massDau , sampleName ),i) elif binning == "Classic" : myDatacard.printDatacard("{3}_mGo{1}_mLSP{2}_datacard_TEST_Classic_bin{0}.txt".format( i , massMom , massDau , sampleName ),i) elif binning == "extSMJ" : myDatacard.printDatacard("{3}_mGo{1}_mLSP{2}_datacard_TEST_extRA2_bin{0}.txt".format( i , massMom , massDau , sampleName ),i)
fileNames = [] sigDir = "/eos/uscms/store/user/awhitbe1/RA2nTupleExtension/divided/" #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_400to750_mLSP_25to550_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_775to1075_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_775to1075_mLSP_525to875_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_525to1000_8TeV_V2.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_1025to1200_8TeV.root") fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_800to1400_mLSP_1_8TeV.root") treeName = "massMom1100_massDau1" T1tttt_datacard = datacard( SMJbins , ["T1tttt"] , [ "QCD500" , "QCD1000" , "ZinvJets" , "WlvJets" , "TTsemiLeptJets" ] ) computeYields( QCD500tree , T1tttt_datacard.binning , T1tttt_datacard.bkgYields["QCD500"] , 6.28 ) computeYields( QCD1000tree , T1tttt_datacard.binning , T1tttt_datacard.bkgYields["QCD1000"] , 0.316 ) computeYields( Zjetstree , T1tttt_datacard.binning , T1tttt_datacard.bkgYields["ZinvJets"] , 0.040 ) computeYields( Wjetstree , T1tttt_datacard.binning , T1tttt_datacard.bkgYields["WlvJets"] , 0.126 ) computeYields( TTjetstree , T1tttt_datacard.binning , T1tttt_datacard.bkgYields["TTsemiLeptJets"] , 0.082 ) for fileName in fileNames : file = TFile( fileName , "READ" ) sigTree = file.Get( treeName ) if sigTree == None : continue
QCD500tree.Add(bkgDir + "QCD_500HT1000_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") QCD1000tree = TChain("RA2TreeFiller/AnalysisTree") QCD1000tree.Add(bkgDir + "QCD_1000HTinf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") Wjetstree = TChain("RA2TreeFiller/AnalysisTree") Wjetstree.Add(bkgDir + "WJetsToLNu_400HTInf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") Wjetstree.Add(bkgDir + "WJetsToLNu_400HTInf_v2_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") Zjetstree = TChain("RA2TreeFiller/AnalysisTree") Zjetstree.Add(bkgDir + "ZJetsToNuNu_400HTinf_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") TTjetstree = TChain("RA2TreeFiller/AnalysisTree") TTjetstree.Add(bkgDir + "TTJets_SemiLeptMGDecays_LPCSUSYPAT_SLIM_ALL_SumJetMass_AnalysisTree.root") referenceCardSMJ = datacard(SMJbins, [sampleName], ["QCD500", "QCD1000", "ZinvJets", "WlvJets", "TTsemiLeptJets"]) referenceCard = datacard(RA2bins, [sampleName], ["QCD500", "QCD1000", "ZinvJets", "WlvJets", "TTsemiLeptJets"]) # print "QCD500" # computeYields( QCD500tree , referenceCard.binning , referenceCard.bkgYields["QCD500"] , 5.582 ) QCD500yields = [0] * referenceCard.binning.nBins QCD500yieldsSMJ = [0] * referenceCardSMJ.binning.nBins QCD500proc = Process(target=computeYields, args=(QCD500tree, referenceCard.binning, QCD500yields, 5.582)) QCD500procSMJ = Process(target=computeYields, args=(QCD500tree, referenceCardSMJ.binning, QCD500yieldsSMJ, 5.582)) # print "QCD1000" # computeYields( QCD1000tree , myDatacard.binning , myDatacard.bkgYields["QCD1000"] , 0.31 ) QCD1000proc = Process( target=computeYields, args=(QCD1000tree, referenceCard.binning, referenceCard.bkgYields["QCD1000"], 0.31) ) QCD1000procSMJ = Process( target=computeYields, args=(QCD1000tree, referenceCardSMJ.binning, referenceCardSMJ.bkgYields["QCD1000"], 0.31)
#fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_400to750_mLSP_25to550_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_775to1075_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_775to1075_mLSP_525to875_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_25to500_8TeV.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_525to1000_8TeV_V2.root") #fileNames.append(sigDir+"19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_1100to1400_mLSP_1025to1200_8TeV.root") fileNames.append( sigDir + "19June2013_SignalTree_SMS_MG_T1tttt_2J_mGo_800to1400_mLSP_1_8TeV.root") treeName = "massMom1100_massDau1" T1tttt_datacard = datacard( SMJbins, ["T1tttt"], ["QCD500", "QCD1000", "ZinvJets", "WlvJets", "TTsemiLeptJets"]) computeYields(QCD500tree, T1tttt_datacard.binning, T1tttt_datacard.bkgYields["QCD500"], 6.28) computeYields(QCD1000tree, T1tttt_datacard.binning, T1tttt_datacard.bkgYields["QCD1000"], 0.316) computeYields(Zjetstree, T1tttt_datacard.binning, T1tttt_datacard.bkgYields["ZinvJets"], 0.040) computeYields(Wjetstree, T1tttt_datacard.binning, T1tttt_datacard.bkgYields["WlvJets"], 0.126) computeYields(TTjetstree, T1tttt_datacard.binning, T1tttt_datacard.bkgYields["TTsemiLeptJets"], 0.082) for fileName in fileNames: