result["PFMET1Phi_Py"] = event.PFMET1Phi[0].py()
      result["PFMET1Phi_Significance"] = event.PFMET1Phi[0].significance()

      result["MVAMET_Pt"] = event.MVAMET[0].pt()
      result["MVAMET_Phi"] = event.MVAMET[0].phi()
      result["MVAMET_Px"] = event.MVAMET[0].px()
      result["MVAMET_Py"] = event.MVAMET[0].py()
      result["MVAMET_Significance"] = event.MVAMET[0].significance()
      
      result["NoPUMET_Pt"] = event.NoPUMET[0].pt()
      result["NoPUMET_Phi"] = event.NoPUMET[0].phi()
      result["NoPUMET_Px"] = event.NoPUMET[0].px()
      result["NoPUMET_Py"] = event.NoPUMET[0].py()
      result["NoPUMET_Significance"] = event.NoPUMET[0].significance()
	
      return result




if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  if sys.argv[2]=="Jetmet":
    runTest(sys.argv[1], JetmetControlPlots())
  elif sys.argv[2]=="Electrons":
    runTest(sys.argv[1], ElectronsControlPlots())
  elif sys.argv[2]=="Muons":
    runTest(sys.argv[1], MuonsControlPlots())

                    svdr = b1SV.DeltaR(b2SV)
                else:
                    svdr = -1

                abb = b1 + b2
                higgs = amu + abb

                # di-b-jets plots
                result["amassBjet"] = abb.M()
                result["aptBjet"] = abb.Pt()
                result["dphiaBjetMET"] = abb.DeltaPhi(met4v)
                result["diBjetdR"] = b1.DeltaR(b2)
                result["dphidiBjet"] = b1.DeltaPhi(b2)
                result["diBjetSVdR"] = svdr

                # Higgs candidate plots
                result["dphiaa"] = abb.DeltaPhi(amu)
                result["aadR"] = abb.DeltaR(amu)
                result["dphiHiggsMET"] = higgs.DeltaPhi(met4v)
                result["hPt"] = higgs.Pt()
                result["hMass"] = higgs.M()
                result["diffMassaa"] = abs(abb.M() - amu.M())

        return result


if __name__ == "__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], EventSelectionControlPlots())
        # declare histograms
        self.add("event","Event number",1000,0,100000)
        self.add("category","event category", self.eventCategories+1, 0, self.eventCategories+1)
        self.add("category_dilep","event category dileptonic final state", 4, 0, 4)
        self.add("category_semilep","event category semileptonic final state", 4, 4, 8)

    def process(self, event):
        """EventSelectionControlPlots_dilep"""

        result = { }

        # event category
        categoryData = event.category
        result["category"] = [ ]
        
        for category in range(self.eventCategories):
            if EventSelection.isInCategory(category, categoryData):
                result["category"].append(category)
        
        result["category_dilep"] = result["category"][:4]
        result["category_semilep"] = result["category"][4:]
        result["event"] = event.event()
        
        return result

if __name__=="__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], EventSelectionControlPlots())

示例#4
0
    def beginJob(self, muChannel=None):
        self._muChannel = muChannel
        # declare histograms
        self.add("weight", "weight", 200, 0, 2)
        self.add("weight_OneExtraLep", "weight_OneExtraLep", 200, 0, 2)
        self.add("weight_TwoExtraLep", "weight_TwoExtraLep", 200, 0, 2)

    def process(self, event):
        """LeptonsReweightingControlPlots"""
        result = {}
        if self._muChannel is None:
            result["weight"] = event.weight(weightList=["Leptons"])
        elif self._muChannel == False:
            result["weight"] = event.weight(weightList=["Leptons"],
                                            forceMode="Electron")
        elif self._muChannel == True:
            result["weight"] = event.weight(weightList=["Leptons"],
                                            forceMode="Muon")
        result["weight_OneExtraLep"] = event.weight(weightList=["Leptons"],
                                                    forceMode="3lep")
        result["weight_TwoExtraLep"] = event.weight(weightList=["Leptons"],
                                                    forceMode="4lep")
        return result


if __name__ == "__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], LeptonsReweightingControlPlots())
        self.add("lvertex", "index of the lepton vertex", 20, -0.5, 19.5)

    def process(self, event):
        """VertexAssociationControlPlots"""
        result = {}
        result["nvertices"] = event.vertices.size()
        if event.vertices.size() == 0: return result
        vertex = event.vertex
        result["vx"] = vertex.x()
        result["vy"] = vertex.y()
        result["vz"] = vertex.z()
        result["vxerr"] = vertex.xError()
        result["vyerr"] = vertex.yError()
        result["vzerr"] = vertex.zError()
        # relevant quantities to monitor: Z vs primary vertex
        bestZ = event.bestZcandidate
        if bestZ is None: return result
        lepton1 = bestZ.daughter(0)
        lepton2 = bestZ.daughter(1)
        result["lepton_dz"] = abs(lepton1.vz() - lepton2.vz())
        result["l1v_dz"] = abs(lepton1.vz() - vertex.z())
        result["l2v_dz"] = abs(lepton2.vz() - vertex.z())
        result["lvertex"] = findPrimaryVertexIndex(bestZ, event.vertices)
        return result


if __name__ == "__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], VertexAssociationControlPlots())
import ROOT
from PatAnalysis.BaseControlPlots import BaseControlPlots

class MonteCarloReweightingControlPlots(BaseControlPlots):
    """A class to create control plots for lumi reweighting"""

    def __init__(self, dir=None, purpose="mcReweighting", dataset=None, mode="plots"):
      # create output file if needed. If no file is given, it means it is delegated
      BaseControlPlots.__init__(self, dir=dir, purpose=purpose, dataset=dataset, mode=mode)
    
    def beginJob(self):
      # declare histograms
      self.add("weight","weight",200,0,2)

    def process(self, event):
      """MonteCarloReweightingControlPlots"""
      result = { }
      result["weight"] = event.weight(weightList=["MonteCarlo"])
      return result

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], MonteCarloReweightingControlPlots())

      # declare histograms
      self.add("HE","HE",200,0,2)
      self.add("HP","HP",200,0,2)
      self.add("HEexcl","HEexcl",200,0,2)
      self.add("HPexcl","HPexcl",200,0,2)
      self.add("HEHE","HEHE",200,0,2)
      self.add("HEHP","HEHP",200,0,2)
      self.add("HPHP","HPHP",200,0,2)
    
    def process(self,event):
      """BtaggingReWeightingControlPlots"""
      result = { }
      result["HE"]     = event.weight(weightList=["Btagging"], forceMode="HE",     btagging=self._btagging)
      result["HP"]     = event.weight(weightList=["Btagging"], forceMode="HP",     btagging=self._btagging)
      result["HEexcl"] = event.weight(weightList=["Btagging"], forceMode="HEexcl", btagging=self._btagging)
      result["HPexcl"] = event.weight(weightList=["Btagging"], forceMode="HPexcl", btagging=self._btagging)
      result["HEHE"]   = event.weight(weightList=["Btagging"], forceMode="HEHE",   btagging=self._btagging)
      result["HEHP"]   = event.weight(weightList=["Btagging"], forceMode="HEHP",   btagging=self._btagging)
      result["HPHP"]   = event.weight(weightList=["Btagging"], forceMode="HPHP",   btagging=self._btagging)
      return result

    def processEvent(self,event,weight = 1.,btagging="CSV"):
      """process event and fill histograms"""
      self.fill(self.process(event,btagging),weight)

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], BtaggingReWeightingControlPlots())

示例#8
0
                result["phi_jab"]=dijet[0].phi()
                delta_phi1=bbarq[0].phi()-dijet[0].phi()
                delta_phi2=bq[0].phi()-dijet[1].phi()
                if delta_phi1>pi:
                  delta_phi1=(2*pi)-delta_phi1
                if delta_phi2>pi:
                    delta_phi2=(2*pi)-delta_phi2
                result["Deltaphi_ajet"]=delta_phi1
                result["Deltaphi_jet"]=delta_phi2
                result["Eta_b"]=bq[0].eta()
                result["Eta_jb"]=dijet[1].eta()
                result["Eta_ab"]=bbarq[0].eta()
                result["Eta_jab"]=dijet[0].eta()
                result["DeltaEta_ajet"]=bbarq[0].eta()-dijet[0].eta()
                result["DeltaEta_jet"]=bq[0].eta()-dijet[1].eta()
      
      return result

def Delta(par1,par2):
  delta_phi=abs(par2.phi()-par1.phi())
  if delta_phi>pi:
    delta_phi=(2*pi)-delta_phi;
  delta=sqrt((delta_phi)**2 + (par1.eta()-par2.eta())**2)
  return delta

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], MatrixElementControlPlots())

    """A class to create control plots for lumi reweighting"""

    def __init__(self, dir=None, category=None, dataset=None, mode="plots"):
      # create output file if needed. If no file is given, it means it is delegated
      BaseControlPlots.__init__(self, dir=dir, purpose="LeptonsReweighting", dataset=dataset, mode=mode)
      self.category = [int(s) for s in dir.GetName().split('_') if s.isdigit()]
      if len(self.category): self.category=self.category[0] 
      else: self.category=None
    
    def beginJob(self, muChannel = None):
      self._muChannel = muChannel
      # declare histograms
      self.add("weight","weight",200,0,2)

    def process(self, event):
      """LeptonsReweightingControlPlots"""
      result = { }
      if self._muChannel is None:
        result["weight"] = event.weight(weightList=["Leptons"], category=self.category)
      elif self._muChannel == False:
        result["weight"] = event.weight(weightList=["Leptons"], category=self.category, forceMode="Electron")
      elif self._muChannel == True:
        result["weight"] = event.weight(weightList=["Leptons"], category=self.category, forceMode="Muon")
      return result

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], LeptonsReweightingControlPlots())

      self.add("lvertex","index of the lepton vertex",20,-0.5,19.5)

    def process(self,event):
      """VertexAssociationControlPlots"""
      result = { }
      result["nvertices"] = event.vertices.size()
      if event.vertices.size()==0 : return result
      vertex = event.vertex
      result["vx"] = vertex.x()
      result["vy"] = vertex.y()
      result["vz"] = vertex.z()
      result["vxerr"] = vertex.xError()
      result["vyerr"] = vertex.yError()
      result["vzerr"] = vertex.zError()
      # relevant quantities to monitor: Z vs primary vertex
      bestZ = event.bestZcandidate
      if bestZ is None: return result
      lepton1 = bestZ.daughter(0)
      lepton2 = bestZ.daughter(1)
      result["lepton_dz"] = abs(lepton1.vz()-lepton2.vz())
      result["l1v_dz"] = abs(lepton1.vz()-vertex.z())
      result["l2v_dz"] = abs(lepton2.vz()-vertex.z())
      result["lvertex"] = findPrimaryVertexIndex(bestZ,event.vertices)
      return result

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], VertexAssociationControlPlots())

      self.add("genMET_Px","GEN MET Px",1000,-500,500)
      self.add("genMET_Py","GEN MET Py",1000,-500,500)
      self.add("MEMET_Pt","Matrix Element MET Pt",600,0,600)
      self.add("MEMET_Phi","Matrix Element MET Phi",320,-3.2,3.2)
      self.add("MEMET_Px","Matrix Element MET Px",1000,-500,500)
      self.add("MEMET_Py","Matrix Element MET Py",1000,-500,500)
      self.add("MEMET_NumberOfNeutrinos","NumberOfNeutrinos",4,0,4)
      
    def process(self,event):
      """Generator Level Mets"""
      result = { }
      result["genMET_Pt"] = event.genMET[0].pt()
      result["genMET_Phi"] = event.genMET[0].phi()
      result["genMET_Px"] = event.genMET[0].px()
      result["genMET_Py"] = event.genMET[0].py()
      
      neutrinos_4v = event.MEMET_4v
      result["MEMET_Pt"]=neutrinos_4v.Pt()
      result["MEMET_Phi"]=neutrinos_4v.Phi()
      result["MEMET_Px"]=neutrinos_4v.Px()
      result["MEMET_Py"]=neutrinos_4v.Py()
      result["MEMET_NumberOfNeutrinos"]=event.NumberOfNeutrinos
      return result


if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], MonteCarloSelectionControlPlots())

        self.add("pv", "pv", 50, 0, 50)
        if self._mode == "plots":
            self._dir.cd()
            self.h_weightSetup = ROOT.TH1F("weightSetup", "weightSetup", 50, 0,
                                           50)
        self.first = True

    def process(self, event):
        """LumiReWeightingControlPlots"""
        if self.first:
            if self._mode == "plots":
                for i in range(50):
                    self.h_weightSetup.SetBinContent(
                        i + 1, event.weight(weightList=["PileUp"], npu=i))
            self.first = False
        result = {}
        result["LumiWeight"] = event.weight(weightList=["PileUp"])
        pileup = event.PileupSummaryInfo
        for pvi in pileup:
            if pvi.getBunchCrossing() == 0:
                npu = pvi.getPU_NumInteractions()
        result["pu"] = npu
        result["pv"] = event.vertices.size()
        return result


if __name__ == "__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], LumiReWeightingControlPlots())
      # declare histograms
      self.add("LumiWeight","LumiWeight",1000,0,10)
      self.add("pu","pu",50,0,50)
      self.add("pv","pv",50,0,50)
      if self._mode=="plots":
        self._dir.cd()
        self.h_weightSetup = ROOT.TH1F("weightSetup","weightSetup",50,0,50)
      self.first = True
    
    def process(self, event):
      """LumiReWeightingControlPlots"""
      if self.first:
        if self._mode=="plots":
          for i in range(50): self.h_weightSetup.SetBinContent(i+1,event.weight(weightList=["PileUp"],npu=i))
        self.first = False
      result = { }
      result["LumiWeight"] = event.weight(weightList=["PileUp"])
      pileup = event.PileupSummaryInfo
      for pvi in pileup:
        if pvi.getBunchCrossing()==0:
          npu = pvi.getPU_NumInteractions()
      result["pu"]= npu
      result["pv"]= event.vertices.size()
      return result

if __name__=="__main__":
  import sys
  from BaseControlPlots import runTest
  runTest(sys.argv[1], LumiReWeightingControlPlots())

            forceMode=self.WP[0] + self.WP[0] + self.WP[0],
            btagging=self._btagging)
        result[self.WP[1] + self.WP[1] + self.WP[1] + "excl"] = event.weight(
            weightList=["Btagging"],
            forceMode=self.WP[1] + self.WP[1] + self.WP[1] + "excl",
            btagging=self._btagging)
        result[self.WP[0] + self.WP[0] + self.WP[0] + "excl"] = event.weight(
            weightList=["Btagging"],
            forceMode=self.WP[0] + self.WP[0] + self.WP[0] + "excl",
            btagging=self._btagging)
        result["0" + self.WP[1] + "excl"] = event.weight(
            weightList=["Btagging"],
            forceMode="0" + self.WP[1] + "excl",
            btagging=self._btagging)
        result["0" + self.WP[0] + "excl"] = event.weight(
            weightList=["Btagging"],
            forceMode="0" + self.WP[0] + "excl",
            btagging=self._btagging)

        return result

    def processEvent(self, event, weight=1., btagging="CSV"):
        """process event and fill histograms"""
        self.fill(self.process(event), weight)


if __name__ == "__main__":
    import sys
    from BaseControlPlots import runTest
    runTest(sys.argv[1], BtaggingReWeightingControlPlots())