def init(self): self.jetGetter = JetGetter("PFAK4CHS") self.dr = ROOT.Math.VectorUtil.DeltaR self.normFactor = self.getNormalizationFactor() self.var = {} self.var["recoEta"] = array('d', [0]) self.var["recoPt"] = array('d', [0]) #self.var["hltEta"] = array('d', [0]) self.var["hltPt"] = array('d', [0]) #self.var["l1Eta"] = array('d', [0]) self.var["l1Pt"] = array('d', [0]) #self.var["s1l1Eta"] = array('d', [0]) self.var["s1l1Pt"] = array('d', [0]) self.var["PUNumInteractions"] = array('d', [0]) self.var["puTrueNumInteractions"] = array('d', [0]) self.var["weight"] = array('d', [0]) # for the PU file run # utils/GetFlatPUDist.py puFile = edm.FileInPath( "CommonFSQFramework.Core/test/mnTrgAnalyzer/PUhists.root" ).fullPath() self.newlumiWeighters = {} #''' self.newlumiWeighters["flat010toflat010"] = edm.LumiReWeighting( puFile, puFile, "Flat0to10/pileup", "Flat0to10/pileup") self.newlumiWeighters["flat010toPU1"] = edm.LumiReWeighting( puFile, puFile, "Flat0to10/pileup", "PU1/pileup") #self.newlumiWeighters["flat010toPU2"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU2/pileup") #self.newlumiWeighters["flat010toPU3"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU3/pileup") #self.newlumiWeighters["flat010toPU4"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU4/pileup") self.newlumiWeighters["flat010toPU5"] = edm.LumiReWeighting( puFile, puFile, "Flat0to10/pileup", "PU5/pileup") self.newlumiWeighters["flat010toPU10"] = edm.LumiReWeighting( puFile, puFile, "Flat0to10/pileup", "PU10/pileup") #''' ''' self.newlumiWeighters["flat2050toPU20"] = edm.LumiReWeighting(puFile, puFile, "Flat20to50/pileup", "PU20/pileup") self.newlumiWeighters["flat2050toPU25"] = edm.LumiReWeighting(puFile, puFile, "Flat20to50/pileup", "PU25/pileup") self.newlumiWeighters["flat2050toPU30"] = edm.LumiReWeighting(puFile, puFile, "Flat20to50/pileup", "PU30/pileup") #''' ''' self.newlumiWeighters["PU20to15"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU15/pileup") self.newlumiWeighters["PU20to18"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU18/pileup") self.newlumiWeighters["PU20to19"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU19/pileup") self.newlumiWeighters["PU20to21"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU21/pileup") self.newlumiWeighters["PU20to22"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU22/pileup") self.newlumiWeighters["PU20to20"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU20/pileup") self.newlumiWeighters["PU20to25"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU25/pileup") #''' for l in self.newlumiWeighters.keys(): self.var[l] = array('d', [0]) self.tree = ROOT.TTree("data", "data") self.GetOutputList().Add(self.tree) for v in self.var: self.tree.Branch(v, self.var[v], v + "/D")
def init( self): self.tree = ROOT.TTree("data", "data") self.GetOutputList().Add(self.tree) self.var = {} self.todoShifts = ["_central"] if not self.isData and self.doPtShiftsJEC: self.todoShifts.append("_ptUp") self.todoShifts.append("_ptDown") if not self.isData and self.doPtShiftsJER: self.todoShifts.append("_jerUp") self.todoShifts.append("_jerDown") # this is ugly # by mimicking the tree structure of the balance method # we will be able to use same plot/fit util for t in self.todoShifts: self.var["tagPt"+t] = array('d', [0]) self.var["tagEta"+t] = array('d', [0]) self.var["probePt"+t] = array('d', [0]) self.var["probeEta"+t] = array('d', [0]) self.var["ptAve"+t] = array('d', [0]) self.var["balance"+t] = array('d', [0]) #self.var["jetEta"+t] = array('d', [0]) #self.var["jetR"+t] = array('d', [0]) self.var["weight"] = array('d', [0]) for v in self.var: self.tree.Branch(v, self.var[v], v+"/D") jet15FileV2 = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/PUJet15V2.root").fullPath() # MC gen distribution puFiles = {} puFiles["dj15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_0.root").fullPath() puFiles["dj15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_05.root").fullPath() puFiles["dj15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_0_95.root").fullPath() puFiles["j15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_0.root").fullPath() puFiles["j15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_05.root").fullPath() puFiles["j15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_0_95.root").fullPath() self.lumiWeighters = {} self.lumiWeighters["_jet15_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1"], "MC", "pileup") self.lumiWeighters["_jet15_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1_05"], "MC", "pileup") self.lumiWeighters["_jet15_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_0_95"], "MC", "pileup") self.lumiWeighters["_dj15fb_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1"], "MC", "pileup") self.lumiWeighters["_dj15fb_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1_05"], "MC", "pileup") self.lumiWeighters["_dj15fb_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_0_95"], "MC", "pileup") self.jetGetter = JetGetter("PF") if hasattr(self, "jetUncFile"): self.jetGetter.setJecUncertainty(self.jetUncFile) sys.stdout.flush()
def init(self): print "Params:", self.etaMax, self.ptMin self.normFactor = self.getNormalizationFactor() self.dr = ROOT.Math.VectorUtil.DeltaR self.tree = ROOT.TTree("data", "data") self.GetOutputList().Add(self.tree) puFile = edm.FileInPath( "CommonFSQFramework.Core/test/mnTrgAnalyzer/PUhists.root" ).fullPath() self.newlumiWeighters = {} self.newlumiWeighters["flat010toPU1"] = edm.LumiReWeighting( puFile, puFile, "Flat0to10/pileup", "PU1/pileup") #self.newlumiWeighters["flat2050toPU20"] = edm.LumiReWeighting(puFile, puFile, "Flat20to50/pileup", "PU20/pileup") self.var = {} self.todoShifts = ["_central"] for t in self.todoShifts: #self.var["ptGen"+t] = array('d', [0]) self.var["ptRec" + t] = array('d', [0]) self.var["etaRec" + t] = array('d', [0]) self.var["ptHLT" + t] = array('d', [0]) self.var["hlt2recRatio" + t] = array('d', [0]) self.var["jetType" + t] = array('d', [0]) self.var["weight"] = array('d', [0]) self.var["weightPU"] = array('d', [0]) self.var["PU"] = array('d', [0]) for v in self.var: self.tree.Branch(v, self.var[v], v + "/D") self.getters = {} ''' ak4 = JetGetter("PFAK4CHS") ak4.disableGenJet() self.getters["AK4CHS"] = ak4 ak5 = JetGetter("PFAK5CHS") ak5.disableGenJet() self.getters["AK5CHS"] = ak5 ak5nochs = JetGetter("PFAK5") ak5nochs.disableGenJet() self.getters["nochsAK5"] = ak5nochs ''' self.getters["gen4"] = None #self.getters["gen5"] = None self.varE = {} sys.stdout.flush()
def init(self): print "XXX init - CMS_FWD_11_002", self.datasetName, self.isData self.todoShifts = ["_central"] if not self.isData and self.doPtShiftsJEC: self.todoShifts.append("_ptUp") self.todoShifts.append("_ptDown") if not self.isData and self.doPtShiftsJER: self.todoShifts.append("_jerUp") self.todoShifts.append("_jerDown") self.hist = {} todoTrg = ["_jet15"] pedroPtBins = array('d', [35, 45, 57, 72, 90, 120, 150, 200]) for shift in self.todoShifts: for trg in todoTrg: t = shift + trg self.hist["etaFwd" + t] = ROOT.TH1F("etaFwd" + t, "etaFwd" + t, 100, -5, 5) self.hist["etaCen" + t] = ROOT.TH1F("etaCen" + t, "etaCen" + t, 100, -5, 5) self.hist["vtx" + t] = ROOT.TH1F("vtx" + t, "vtx" + t, 10, -0.5, 9.5) self.hist["ptFwd" + t] = ROOT.TH1F("ptFwd" + t, "ptFwd" + t, len(pedroPtBins) - 1, pedroPtBins) self.hist["ptCen" + t] = ROOT.TH1F("ptCen" + t, "ptCen" + t, len(pedroPtBins) - 1, pedroPtBins) self.hist["xs" + t] = ROOT.TH1F("xs" + t, "xs" + t, 1, 0, 1) # follow the histogram naming convention even if it makes no sense for gen - needed for drawPlots.py self.hist["genFwd"] = ROOT.TH1F("genJetFwd_central_jet15", "genJetFwd_central_jet15", len(pedroPtBins) - 1, pedroPtBins) self.hist["genCen"] = ROOT.TH1F("genJetCen_central_jet15", "genJetCen_central_jet15", len(pedroPtBins) - 1, pedroPtBins) self.hist["xsGen"] = ROOT.TH1F("genTot_central_jet15", "genTot_central_jet15", 1, 0, 1) for h in self.hist: self.hist[h].Sumw2() self.GetOutputList().Add(self.hist[h]) puFiles = {} # CommonFSQFramework.Core/test/MNxsectionAna/ jet15FileV2 = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/PUJet15V2.root" ).fullPath() # MC gen distribution puFiles["dj15_1"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_0.root" ).fullPath() puFiles["dj15_1_05"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_05.root" ).fullPath() puFiles["dj15_0_95"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_0_95.root" ).fullPath() puFiles["j15_1"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_0.root" ).fullPath() puFiles["j15_1_05"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_05.root" ).fullPath() puFiles["j15_0_95"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_0_95.root" ).fullPath() self.lumiWeighters = {} self.lumiWeighters["_jet15_central"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_1"], "MC", "pileup") self.lumiWeighters["_jet15_puUp"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_1_05"], "MC", "pileup") self.lumiWeighters["_jet15_puDown"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_0_95"], "MC", "pileup") self.lumiWeighters["_dj15fb_central"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_1"], "MC", "pileup") self.lumiWeighters["_dj15fb_puUp"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_1_05"], "MC", "pileup") self.lumiWeighters["_dj15fb_puDown"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_0_95"], "MC", "pileup") self.jetGetter = JetGetter("PF") if hasattr(self, "jetUncFile"): self.jetGetter.setJecUncertainty(self.jetUncFile)
slaveParams["threshold"] = 35. #slaveParams["doPtShiftsJEC"] = False slaveParams["doPtShiftsJEC"] = True #slaveParams["doPtShiftsJER"] = False slaveParams["doPtShiftsJER"] = True slaveParams["recoJetCollection"] = "pfJets" #slaveParams["recoJetCollection"] = "pfJetsSmear" slaveParams["recoJetCollectionBaseReco"] = "pfJets" slaveParams["recoJetCollectionGEN"] = "pfJets2Gen" slaveParams["jetID"] = "pfJets_jetID" #slaveParams["recoJetCollection"] = "caloJets" #slaveParams["recoJetCollection"] = "caloJetsSmear" #jetUncFile = "START42_V11_AK5PF_Uncertainty.txt" jetUncFile = "START41_V0_AK5PF_Uncertainty.txt" slaveParams["jetUncFile"] = edm.FileInPath( "CommonFSQFramework.Core/test/MNxsectionAna/" + jetUncFile).fullPath() CMS_FWD_11_002.runAll(treeName="mnXS", slaveParameters=slaveParams, sampleList=sampleList, maxFilesMC=maxFilesMC, maxFilesData=maxFilesData, nWorkers=nWorkers, outFile="plotsCMS_FWD_11_002.root")
def init(self): BalanceTreeProducer.BalanceTreeProducer.init(self) self.addExternalVar(["genW"]) self.addExternalVar(["hltPtAve"]) self.addExternalVar(["hltPtCen"]) self.addExternalVar(["hltPtFwd"]) self.addExternalVar(["hltCaloPtAve"]) self.addExternalVar(["hltCaloPtCen"]) self.addExternalVar(["hltCaloPtFwd"]) #self.addExternalVar(["hltL1MatchPtCen"]) #self.addExternalVar(["hltL1MatchPtFwd"]) #self.addExternalVar(["l1DoubleJet"]) #self.addExternalVar(["l1SingleJetCentral"]) #self.addExternalVar(["l1SingleJetForward"]) self.addExternalVar(["s1l1SingleJetCentral"]) self.addExternalVar(["s1l1SingleJetForward"]) self.addExternalVar(["s1l1SingleJetAny"]) #hltgetter = BaseTrigger.TriggerObjectsGetter(self.fChain, "hltAK4PFJetsCorrected") #hltgetter = BaseTrigger.TriggerObjectsGetter(self.fChain, "PFAK4CHSnewjets") hltgetter = BaseTrigger.TriggerObjectsGetter( self.fChain, "recoPFAK4ChsCorrectedMyRhop4") #hltgetter = BaseTrigger.TriggerObjectsGetter(self.fChain, "recoPFAK4ChsCorrectedp4") print "Note: will go through reco jets and not hlt jets!" # note: this file is a mess. Source collection defined in couple of places, so look out self.hltAveFromPython = BaseTrigger.PTAveProperTrigger(hltgetter) self.addExternalVar(["hltAveFromPython"]) self.addExternalVar(["hltCaloPreselection"]) ''' self.addExternalVar(["s1DoubleJetCFDphi31"]) self.addExternalVar(["s1DoubleJetCFDphi27"]) self.addExternalVar(["s1DoubleJetCFDphi24"]) self.addExternalVar(["s1DoubleJetCFDphi20"]) self.addExternalVar(["s1DoubleJetCFDphi17"]) ''' self.addExternalVar(["PUNumInteractions"]) self.addExternalVar(["puTrueNumInteractions"]) #self.addExternalVar(["trgptAve60CenFwd"]) #self.addExternalVar(["trgptAve80CenFwd"]) # for the PU file run # utils/GetFlatPUDist.py puFile = edm.FileInPath( "CommonFSQFramework.Core/test/mnTrgAnalyzer/PUhists.root" ).fullPath() self.newlumiWeighters = {} ''' self.newlumiWeighters["flat010toflat010"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "Flat0to10/pileup") self.newlumiWeighters["flat010toPU1"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU1/pileup") #self.newlumiWeighters["flat010toPU2"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU2/pileup") #self.newlumiWeighters["flat010toPU3"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU3/pileup") #self.newlumiWeighters["flat010toPU4"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU4/pileup") self.newlumiWeighters["flat010toPU5"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU5/pileup") self.newlumiWeighters["flat010toPU10"] = edm.LumiReWeighting(puFile, puFile, "Flat0to10/pileup", "PU10/pileup") #''' #''' self.newlumiWeighters["flat2050toPU10"] = edm.LumiReWeighting( puFile, puFile, "Flat20to50/pileup", "PU10/pileup") self.newlumiWeighters["flat2050toPU15"] = edm.LumiReWeighting( puFile, puFile, "Flat20to50/pileup", "PU15/pileup") self.newlumiWeighters["flat2050toPU20"] = edm.LumiReWeighting( puFile, puFile, "Flat20to50/pileup", "PU20/pileup") self.newlumiWeighters["flat2050toPU25"] = edm.LumiReWeighting( puFile, puFile, "Flat20to50/pileup", "PU25/pileup") self.newlumiWeighters["flat2050toPU30"] = edm.LumiReWeighting( puFile, puFile, "Flat20to50/pileup", "PU30/pileup") #''' ''' self.newlumiWeighters["PU20to15"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU15/pileup") self.newlumiWeighters["PU20to18"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU18/pileup") self.newlumiWeighters["PU20to19"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU19/pileup") self.newlumiWeighters["PU20to21"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU21/pileup") self.newlumiWeighters["PU20to22"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU22/pileup") self.newlumiWeighters["PU20to20"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU20/pileup") self.newlumiWeighters["PU20to25"] = edm.LumiReWeighting(puFile, puFile, "PU20/pileup", "PU25/pileup") #''' self.addExternalVar(self.newlumiWeighters.keys())
def init( self): self.variantFilter = BaseDijetAna.variant(self.variant) if not self.isData: #self.hltMCWeighter = HLTMCWeighter("HLT_Jet15U") self.HLTMCWeighterJ15Raw = HLTMCWeighter("HLT_Jet15U_raw") self.HLTMCWeighterJ15L1Raw = HLTMCWeighter("HLT_Jet15U_L1Seeding_raw") self.HLTMCWeighterJ15FBL1Raw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_L1Seeding_raw") self.HLTMCWeighterJ15FBRaw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_raw") self.normFactor = self.getNormalizationFactor() #sys.stdout = sys.stderr #self.pr = cProfile.Profile() print "XXX init - MNxsAnalyzerClean", self.datasetName, self.isData self.todoShifts = ["_central"] if not self.isData and self.doPtShiftsJEC: self.todoShifts.append("_jecUp") self.todoShifts.append("_jecDown") if not self.isData and self.doPtShiftsJER: self.todoShifts.append("_jerUp") self.todoShifts.append("_jerDown") # since shifts for PU are in fact changes in weight # there is no sense to repeat whole analaysis # we will use the central value self.shiftsPU = ["_central"] if not self.isData and self.doShiftsPU: self.shiftsPU.append("_puUp") self.shiftsPU.append("_puDown") self.hist = {} todoTrg = ["_jet15", "_dj15fb"] binsNew = self.variantFilter.bins() # note: set gives as unique items, since _central is repeated self.hist["ptHat"] = ROOT.TH1F("ptHat", "ptHat", 100, 0, 50) for shift in set(self.todoShifts+self.shiftsPU): for trg in todoTrg: t = shift+trg self.hist["ptLead"+t] = ROOT.TH1F("ptLead"+t, "ptLead"+t, 100, 0, 100) self.hist["ptSublead"+t] = ROOT.TH1F("ptSublead"+t, "ptSublead"+t, 100, 0, 100) self.hist["etaLead"+t] = ROOT.TH1F("etaLead"+t, "etaLead"+t, 100, -5, 5) self.hist["etaSublead"+t] = ROOT.TH1F("etaSublead"+t, "etaSublead"+t, 100, -5, 5) self.hist["xsVsDeltaEta"+t] = ROOT.TH1F("xs"+t, "xs"+t, len(binsNew)-1, binsNew) self.hist["miss"+t] = self.hist["xsVsDeltaEta"+t].Clone("miss"+t) self.hist["vtx"+t] = ROOT.TH1F("vtx"+t, "vtx"+t, 10, -0.5, 9.5) if self.unfoldEnabled: dummy = ROOT.TH2F("dummy"+t, "dummy"+t, len(binsNew)-1, binsNew, len(binsNew)-1, binsNew) self.hist["response"+t]= ROOT.RooUnfoldResponse(self.hist["xsVsDeltaEta"+t], self.hist["xsVsDeltaEta"+t], dummy, "response"+t,"response"+t) # in principle trigger does not applies to gen plots. We keep consistent naming though, so the unfolded result to gen level plots is possible # in each category self.hist["detaGen_jet15"] = ROOT.TH1F("detaGen_central_jet15", "detaGen_central_jet15", len(binsNew)-1, binsNew) self.hist["detaGen_dj15fb"] = ROOT.TH1F("detaGen_central_dj15fb", "detaGen_central_dj15fb", len(binsNew)-1, binsNew) if self.onlyPtHatReweighing: self.var = {} self.var["leadPt"] = array('d', [0]) self.var["leadEta"] = array('d', [0]) self.var["weight"] = array('d', [0]) # only jet15 trigger?? #self.var["alphaQCD"] = array('d', [0]) self.var["qScale"] = array('d', [0]) self.tree = ROOT.TTree("data", "data") for v in self.var: self.tree.Branch(v, self.var[v], v+"/D") self.addToOutput(self.tree) else: for h in self.hist: if not h.startswith("response"): self.hist[h].Sumw2() #self.GetOutputList().Add(self.hist[h]) self.addToOutput(self.hist[h]) if self.applyPtHatReweighing and not self.isData: fp = "CommonFSQFramework/Core/test/MNxsectionAna/" todo = ["ptHatWeighters.root"] self.ptHatW = [] for t in todo: ptHatFileName = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/"+t).fullPath() ptHatFile = ROOT.TFile(ptHatFileName) self.ptHatW.append(ptHatFile.Get(self.datasetName+"/ptHatW")) puFiles = {} # CommonFSQFramework.Core/test/MNxsectionAna/ jet15FileV2 = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/PUJet15V2.root").fullPath() # MC gen distribution puFiles["dj15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_0.root").fullPath() puFiles["dj15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_05.root").fullPath() puFiles["dj15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_0_95.root").fullPath() puFiles["j15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_0.root").fullPath() puFiles["j15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_05.root").fullPath() puFiles["j15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_0_95.root").fullPath() self.lumiWeighters = {} self.lumiWeighters["_jet15_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1"], "MC", "pileup") self.lumiWeighters["_jet15_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1_05"], "MC", "pileup") self.lumiWeighters["_jet15_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_0_95"], "MC", "pileup") self.lumiWeighters["_dj15fb_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1"], "MC", "pileup") self.lumiWeighters["_dj15fb_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1_05"], "MC", "pileup") self.lumiWeighters["_dj15fb_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_0_95"], "MC", "pileup") self.jetGetter = BetterJetGetter("PFAK5") self.getterForTriggerModelling = BetterJetGetter("CaloRaw")
def init( self): if not self.isData: #self.hltMCWeighter = HLTMCWeighter("HLT_Jet15U") self.HLTMCWeighterJ15Raw = HLTMCWeighter("HLT_Jet15U_raw") self.HLTMCWeighterJ15L1Raw = HLTMCWeighter("HLT_Jet15U_L1Seeding_raw") self.HLTMCWeighterJ15FBL1Raw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_L1Seeding_raw") self.HLTMCWeighterJ15FBRaw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_raw") self.normFactor = self.getNormalizationFactor() #sys.stdout = sys.stderr #self.pr = cProfile.Profile() print "XXX init - MNxsAnalyzer", self.datasetName, self.isData self.todoShifts = ["_central"] if not self.isData and self.doPtShiftsJEC: self.todoShifts.append("_jecUp") self.todoShifts.append("_jecDown") if not self.isData and self.doPtShiftsJER: self.todoShifts.append("_jerUp") self.todoShifts.append("_jerDown") self.hist = {} todoTrg = ["_jet15", "_dj15fb"] binningDeta = (19, 0, 9.5) for shift in self.todoShifts: for trg in todoTrg: t = shift+trg self.hist["ptLead"+t] = ROOT.TH1F("ptLead"+t, "ptLead"+t, 100, 0, 100) self.hist["ptSublead"+t] = ROOT.TH1F("ptSublead"+t, "ptSublead"+t, 100, 0, 100) self.hist["etaLead"+t] = ROOT.TH1F("etaLead"+t, "etaLead"+t, 100, -5, 5) self.hist["etaSublead"+t] = ROOT.TH1F("etaSublead"+t, "etaSublead"+t, 100, -5, 5) self.hist["xsVsDeltaEta"+t] = ROOT.TH1F("xs"+t, "xs"+t, binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["xsVsDeltaEtaGen"+t] = ROOT.TH1F("xsGen"+t, "xsGen"+t, binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["xsVsDeltaEtaFake"+t] = ROOT.TH1F("xsFake"+t, "xsFake"+t, binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["xsVsDeltaEtaMiss"+t] = ROOT.TH1F("xsMiss"+t, "xsMiss"+t, binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["vtx"+t] = ROOT.TH1F("vtx"+t, "vtx"+t, 10, -0.5, 9.5) if self.unfoldEnabled: self.hist["response"+t]= ROOT.RooUnfoldResponse(binningDeta[0], binningDeta[1], binningDeta[2], "response"+t,"response"+t) self.hist["evcnt"] = ROOT.TH1F("evcnt_central_jet15", "evcnt_central_jet15", 1, -0.5, 0.5) #self.hist["detaGen"] = ROOT.TH1F("detaGen_central_sum", "detaGen_central_sum", binningDeta[0], binningDeta[1], binningDeta[2]) # in principle trigger does not applies to gen plots. We keep consistent naming though, so the unfolded result to gen level plots is possible # in each category self.hist["detaGen_jet15"] = ROOT.TH1F("detaGen_central_jet15", "detaGen_central_jet15", binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["detaGen_dj15fb"] = ROOT.TH1F("detaGen_central_dj15fb", "detaGen_central_dj15fb", binningDeta[0], binningDeta[1], binningDeta[2]) self.hist["detaGenVsRec"] = ROOT.TH2F("detaGenVsRec_central_jet15", "detaGenVsRec_central_jet15",\ binningDeta[0]*20, binningDeta[1], binningDeta[2],\ binningDeta[0]*20, binningDeta[1], binningDeta[2]) if self.onlyPtHatReweighing: self.var = {} self.var["leadPt"] = array('d', [0]) self.var["leadEta"] = array('d', [0]) self.var["weight"] = array('d', [0]) # only jet15 trigger?? #self.var["alphaQCD"] = array('d', [0]) self.var["qScale"] = array('d', [0]) self.tree = ROOT.TTree("data", "data") for v in self.var: self.tree.Branch(v, self.var[v], v+"/D") self.addToOutput(self.tree) else: for h in self.hist: if not h.startswith("response"): self.hist[h].Sumw2() #self.GetOutputList().Add(self.hist[h]) self.addToOutput(self.hist[h]) if self.applyPtHatReweighing and not self.isData: fp = "CommonFSQFramework.Core/test/MNxsectionAna/" todo = ["ptHatWeighters.root"] #todo = ["ptHatWeighters_invx_pass1.root_invX", # "ptHatWeighters_invx_pass2.root_invX", # "ptHatWeighters_invx_pass3.root_invX",] self.ptHatW = [] for t in todo: ptHatFileName = edm.FileInPath("CommonFSQFramework.Core/test/MNxsectionAna/"+t).fullPath() ptHatFile = ROOT.TFile(ptHatFileName) self.ptHatW.append(ptHatFile.Get(self.datasetName+"/ptHatW")) #print "PTHat weighter set to", self.datasetName+"/ptHatW" #print "PTHat test@30:", self.ptHatW.Eval(30) puFiles = {} # CommonFSQFramework.Core/test/MNxsectionAna/ jet15FileV2 = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/PUJet15V2.root").fullPath() # MC gen distribution puFiles["dj15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_0.root").fullPath() puFiles["dj15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_05.root").fullPath() puFiles["dj15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_0_95.root").fullPath() puFiles["j15_1"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_0.root").fullPath() puFiles["j15_1_05"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_05.root").fullPath() puFiles["j15_0_95"] = edm.FileInPath("CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_0_95.root").fullPath() self.lumiWeighters = {} self.lumiWeighters["_jet15_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1"], "MC", "pileup") self.lumiWeighters["_jet15_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_1_05"], "MC", "pileup") self.lumiWeighters["_jet15_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["j15_0_95"], "MC", "pileup") self.lumiWeighters["_dj15fb_central"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1"], "MC", "pileup") self.lumiWeighters["_dj15fb_puUp"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_1_05"], "MC", "pileup") self.lumiWeighters["_dj15fb_puDown"] = edm.LumiReWeighting(jet15FileV2, puFiles["dj15_0_95"], "MC", "pileup") #self.jetGetter = JetGetter("PF") #if hasattr(self, "jetUncFile"): # self.jetGetter.setJecUncertainty(self.jetUncFile) self.jetGetter = BetterJetGetter("PFAK5")
def init(self): #self.pr = cProfile.Profile() print "Params:", self.etaMax, self.ptMin if not self.isData: #self.hltMCWeighter = HLTMCWeighter("HLT_Jet15U") self.HLTMCWeighterJ15Raw = HLTMCWeighter("HLT_Jet15U_raw") self.HLTMCWeighterJ15L1Raw = HLTMCWeighter( "HLT_Jet15U_L1Seeding_raw") #self.HLTMCWeighterDJ15FBRaw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_raw") #self.HLTMCWeighterDJ15L1FBRaw = HLTMCWeighter("HLT_DoubleJet15U_ForwardBackward_L1Seeding_raw") self.normFactor = self.getNormalizationFactor() self.dphi = ROOT.Math.VectorUtil.DeltaPhi self.tree = ROOT.TTree("data", "data") #self.GetOutputList().Add(self.tree) self.addToOutput(self.tree) self.var = {} self.histos = {} self.histos["evcnt"] = ROOT.TH1F("evcnt_central_jet15", "evcnt_central_jet15", 1, -0.5, 0.5) self.todoShifts = ["_central"] if not self.isData and self.doPtShiftsJEC: #self.todoShifts.append("_ptUp") #self.todoShifts.append("_ptDown") self.todoShifts.append("_jecUp") self.todoShifts.append("_jecDown") if not self.isData and self.doPtShiftsJER: self.todoShifts.append("_jerUp") self.todoShifts.append("_jerDown") trg = "_jet15" for t in self.todoShifts: self.var["tagPt" + t] = array('d', [0]) self.var["tagEta" + t] = array('d', [0]) self.var["probePt" + t] = array('d', [0]) self.var["probeEta" + t] = array('d', [0]) self.var["ptAve" + t] = array('d', [0]) self.var["balance" + t] = array('d', [0]) #//self.var["veto1"+t] = array('d', [0]) self.var["veto2" + t] = array('d', [0]) histoPostFix = t + trg self.histos["ptProbe" + t] = ROOT.TH1F("ptProbe" + histoPostFix, "ptProbe" + histoPostFix, 100, 0, 100) self.histos["ptTag" + t] = ROOT.TH1F("ptTag" + histoPostFix, "ptTag" + histoPostFix, 100, 0, 100) self.histos["etaProbe" + t] = ROOT.TH1F("etaProbe" + histoPostFix, "etaProbe" + histoPostFix, 35, 1.3, 4.8) self.histos["etaTag" + t] = ROOT.TH1F("etaTag" + histoPostFix, "etaTag" + histoPostFix, 15, 0, 1.5) self.histos["nvtx" + t] = ROOT.TH1F("nvtx" + histoPostFix, "nvtx" + histoPostFix, 10, -0.5, 9.5) for t in self.histos: #self.histos[t][1] = ROOT.TH1F(name, name, nbins, self.histos[t][2], self.histos[t][3]) self.histos[t].Sumw2() #self.GetOutputList().Add(self.histos[t]) self.addToOutput(self.histos[t]) self.var["weight"] = array('d', [0]) for v in self.var: self.tree.Branch(v, self.var[v], v + "/D") jet15FileV2 = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/PUJet15V2.root" ).fullPath() # MC gen distribution puFiles = {} puFiles["dj15_1"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_0.root" ).fullPath() puFiles["dj15_1_05"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_1_05.root" ).fullPath() puFiles["dj15_0_95"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_dj15_0_95.root" ).fullPath() puFiles["j15_1"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_0.root" ).fullPath() puFiles["j15_1_05"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_1_05.root" ).fullPath() puFiles["j15_0_95"] = edm.FileInPath( "CommonFSQFramework/Core/test/MNxsectionAna/data/pu_j15_0_95.root" ).fullPath() self.lumiWeighters = {} self.lumiWeighters["_jet15_central"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_1"], "MC", "pileup") self.lumiWeighters["_jet15_puUp"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_1_05"], "MC", "pileup") self.lumiWeighters["_jet15_puDown"] = edm.LumiReWeighting( jet15FileV2, puFiles["j15_0_95"], "MC", "pileup") self.lumiWeighters["_dj15fb_central"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_1"], "MC", "pileup") self.lumiWeighters["_dj15fb_puUp"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_1_05"], "MC", "pileup") self.lumiWeighters["_dj15fb_puDown"] = edm.LumiReWeighting( jet15FileV2, puFiles["dj15_0_95"], "MC", "pileup") if self.HLT2015TempWorkaround: #self.jetGetter = JetGetter("PFAK4CHS", jetColOverride="recoPFAK4ChsCorrectedMyRhop4") #self.jetGetter = JetGetter("PFAK4CHS", jetColOverride="recoPFAK4ChsCorrectedp4") self.jetGetter = JetGetter( "PFAK4CHS", jetColOverride="hltAK4PFJetsCorrectedp4") #self.jetGetter = JetGetter("PFAK4CHS") #self.jetGetter = JetGetter("PFAK5CHS") #self.jetGetter = JetGetter("PF") self.jetGetter.disableGenJet() self.jetGetter.disableJetId() #self.jetGetter = GenJetProxy() else: self.jetGetter = JetGetter("PFAK5") #self.jetGetter = JetGetter("PFlegacy") self.jetGetter.disableGenJet() #self.jetGetter = BetterJetGetter("PFAK5") #self.jetGetter = BetterJetGetter("Calo") ''' if self.isData: self.jetGetter = JetGetter("PFAK5") else: self.jetGetter = JetGetter("PFlegacy") ''' self.varE = {} sys.stdout.flush()